The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
Google UNIX.COM
Home Forums Register Rules & FAQ Members List Arcade Search Today's Posts Mark Forums Read


UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!


Other UNIX.COM Threads You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Sort command - strange behaviour miwinter UNIX for Advanced & Expert Users 16 05-29-2008 04:19 AM
Error message while executing the shell script ajayyaduwanshi Shell Programming and Scripting 4 10-25-2007 04:12 AM
Strange error message with regex test... fgilain Shell Programming and Scripting 4 05-31-2006 06:52 PM
ed strange error message frenki Shell Programming and Scripting 6 10-29-2004 03:00 AM
Strange "Unable to load interpreter" message! solvman UNIX for Advanced & Expert Users 6 05-15-2002 06:03 PM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 04-25-2007
Registered User
 

Join Date: Mar 2007
Posts: 19
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiReddit! Stumble this Post!Spurl this Post!
a strange message when executing the sort command

Dear all,
when I issue the command:
gunzip -c file.gz |sort
the command is executed normally and correctly but a message keeps appearing everytime I run the command:

the message:
sort: missing NEWLINE added at end of input file STDIN

Does anyone know what is the meaning of this message?
Thanks in advance
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 04-25-2007
zazzybob's Avatar
Registered Geek
 

Join Date: Dec 2003
Location: Melbourne, Australia
Posts: 2,100
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiReddit! Stumble this Post!Spurl this Post!
It's doing exactly what it says - it's adding a newline to the end of your input file as one isn't there, e.g.
Code:
$ echo -n "foo" | sort
sort: warning: missing NEWLINE added at EOF
foo
$ echo "foo" | sort
foo
You can suppress this benign message by redirecting STDERR to /dev/null, or by appending a newline to your input file, e.g.:
Code:
$ ( gzip -dc ./file.gz; echo ) | sort
-or-
$ gzip -dc ./file.gz | sort 2>/dev/null
You can verify that the last line of your input file doesn't contain a newline with:
Code:
$ gzip -dc ./file.gz | tail -1 | od -c
Cheers,
ZB
Reply With Quote
  #3 (permalink)  
Old 04-27-2007
Registered User
 

Join Date: Mar 2007
Posts: 19
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiReddit! Stumble this Post!Spurl this Post!
Dear Zazzybob,
thanks so much for the information, but i am so new to unix, and I can't completely follow up with u. I need to understand the source of the problem, that is why the sort command is adding a new line at the end of the file.
and when i execute the command : gunzip -c file.gz |tail -1 , the result is the last two lines, not the last line only.
Thanks
Reply With Quote
  #4 (permalink)  
Old 04-27-2007
...@...
 

Join Date: Feb 2004
Location: NM
Posts: 3,236
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiReddit! Stumble this Post!Spurl this Post!
Unix files that us humans consider text, use ASCII 10 for carriage control - it's called a newline character.

Unzip the file.
Open the file in an editor, go to the end of the very last line and hit the return key on the keyboard. That will add a newline (\n) to the end of the file. Save the changed file. Re-zip it.
Reply With Quote
Google UNIX.COM
Reply



Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -7. The time now is 05:50 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008 The CEP Blog All Rights Reserved -Ad Management by RedTyger

Search Engine Optimization by vBSEO 3.1.0

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102