![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| UNIX for Advanced & Expert Users Advanced UNIX and Linux questions go here. Expert-to-Expert. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Simple Question | aforball | UNIX for Dummies Questions & Answers | 3 | 03-04-2008 01:26 PM |
| sed - simple question | scotty_123 | Shell Programming and Scripting | 13 | 03-28-2007 11:23 PM |
| Simple C question... Hopefully it's simple | Xeed | High Level Programming | 6 | 12-15-2006 11:29 AM |
| Ok simple question for simple knowledge... | Corrail | UNIX for Dummies Questions & Answers | 1 | 11-28-2005 10:03 AM |
| Simple ksh question | frustrated1 | Shell Programming and Scripting | 1 | 11-05-2003 09:41 AM |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Simple Question
Friends,
I did following exercise $ echo '' > test $ od -b test $ echo "">test $ od -b test $echo > test $od -b test Every time I got the following output 0000000 012 0000001 But 012 is octal value for new line character . Even though there is no apperent new line character in test file the output of command showed 012. Will anybody please explain the reason for the output ? |
| Forum Sponsor | ||
|
|
|
#2
|
||||
|
||||
|
What is the purpose of your input?
Also, what flavor of UNIX is this on? I believe that a file begins with a newline char or some other unseen chars. I had trouble in a script one time trying to test for 0 bytes because of bogus chars in the file even though it shows 0 bytes from an "ls filename" output. Weird...
__________________
My brain is your brain |
|
#3
|
|||
|
|||
|
j1yant,
From the man page for echo, I found the following... DESCRIPTION The echo utility writes its arguments, separated by BLANKs and terminated by a NEWLINE, to the standard output. If there are no arguments, only the NEWLINE character will be written. So this explains why you always get a newline. Also, in that man page, you'll see that some echos ( shell dependant ) allow for a flag to be passed to eliminate the adding of a NEWLINE to the end of the character. Hope this helps... T |
|
#4
|
|||
|
|||
|
Kelam...
Are you sure it's a NEWLINE character at the start of every file? |
|
#5
|
||||
|
||||
|
If you think about it a file with nothing in it only has a newline in it...
Because the file as "spaces followed by a newline". So your answer is yes. But the file has to be empty for this to be the case. That is probably why my 0 byte test failed. here is my output using your test criteria. -root:/tmp> echo "" > test # no blank in between -root:/tmp> od -b test 0000000 012 0000001 -root:/tmp> echo > test #echo nothing -root:/tmp> od -b test 0000000 012 0000001 -root:/tmp> echo " " > test # echo one blank character -root:/tmp> od -b test 0000000 040 012 0000002
__________________
My brain is your brain |
|
#6
|
|||
|
|||
|
Troccola,
Yes ,in the man page explantion is given as to why new line character appears. I want to know which flag you passed to eliminate new line character. Will you please demonstrate it? J1yant |
|
#7
|
||||
|
||||
|
With echo, you would want to do something like this:
echo "\c" > file If that doesn't work, you might need to do this: echo -e "\c" > file But that best way to do it is: >file |
||||
| Google The UNIX and Linux Forums |