|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
You don't need a fax machine to get faxes. Get a fax-to-email fax number from CallWave. Try it free.
|
|
#1
|
|||
|
|||
|
'cat' and 'echo' advice: how to show a file in 'cat' format instead of 'echo'
Hello,
I'm writing a script that displays a current file I have in the pwd. The script line reads: echo `cat movdb.dat`;; (It's inside a case statement) Anyway, echo displays the contents of the file with single spaces, between words and characters and such. If I were to cat the file directly from the cmd line, such as : $ cat movdb.dat then it would have all the spacing that makes it look nice. But when I do it with echo, it does not include all the spaces and such. How can I make it so it looks like when I exe. "cat movdb.dat" from the cmd line? Thank you. -vi |
|
#2
|
|||
|
|||
|
Instead of:
echo `cat movdb.dat`;; use: `cat movdb.dat` ;; Make sure to use backticks ( ` ) and not single quotes. Backticks should tell your shell to execute this command. You may need to use the full path to cat. Eg: /bin/cat |
|
#3
|
|||
|
|||
|
ah damn, so simple.
thanks for the revelation. -vi |
|
#4
|
|||
|
|||
|
hmm. it does not work, but i think i know why.
the particular file i am trying to cat has spaces. anyway, i changed the program to: `cat movdb.dat` ( this is a movie database program i am trying to create, and i'm supposed to list this dat file which i created ) but when i do that, it says this: ./prog6: 0001|Lord: command not found its trying to cat the information in that movdb.dat file, but when it hits the first "space" or "blank" ( blank space ) it gets that error. any suggestions now ? btw, the file is in the same directory, so i won't need the full pathname. ##### also, the first line of the movdb.dat file is: 0001|Lord of the Rings |Bilbo Baggins |Action |12/12/52| 900000 ##### -vi |
|
#5
|
|||
|
|||
|
Lose the backticks. To display a file just use:
cat movdb.dat Add in the semicolons if you want to terminate the case selection on the same line. If you got the cat command to work on the command line, why are you screwing around with echo and backticks in the script? |
|
#6
|
||||
|
||||
|
Quote:
Excellent. It finally displays it just the way I want it. Quote:
I thought backticks where needed whenever you need something to execute on the cmd line. 'echo' was truly a intellectual blunder on my part, however, since I echo everything. Thanks for your help, in case you didn't know, i'm new to UNIX scripting . Currently in taking an Intro to UNiX class, and its my last program for this semester. -vi |
![]() |
| Viewing: Dev Shed Forums > Operating Systems > UNIX Help > 'cat' and 'echo' advice: how to show a file in 'cat' format instead of 'echo' |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|