The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com



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 !!

More UNIX and Linux Forum Topics 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 07:19 AM
Error message while executing the shell script ajayyaduwanshi Shell Programming and Scripting 4 10-25-2007 07:12 AM
Strange error message with regex test... fgilain Shell Programming and Scripting 4 05-31-2006 09:52 PM
ed strange error message frenki Shell Programming and Scripting 6 10-29-2004 06:00 AM
Strange "Unable to load interpreter" message! solvman UNIX for Advanced & Expert Users 6 05-15-2002 09:03 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 04-25-2007
marwan marwan is offline
Registered User
  
 

Join Date: Mar 2007
Posts: 20
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
  #2 (permalink)  
Old 04-25-2007
zazzybob's Avatar
zazzybob zazzybob is offline Forum Advisor  
Registered Geek
  
 

Join Date: Dec 2003
Location: Melbourne, Australia
Posts: 2,100
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
  #3 (permalink)  
Old 04-27-2007
marwan marwan is offline
Registered User
  
 

Join Date: Mar 2007
Posts: 20
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
  #4 (permalink)  
Old 04-27-2007
jim mcnamara jim mcnamara is offline Forum Staff  
...@...
  
 

Join Date: Feb 2004
Location: NM
Posts: 5,754
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.
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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

BB 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 -4. The time now is 05:16 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0