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 > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Outputting from two input files. Liguidsoul Shell Programming and Scripting 5 04-10-2007 02:31 AM
input a line at the beginning of every file in a directory? Terrible Shell Programming and Scripting 6 08-16-2006 06:42 AM
How to prompt for input & accept input in ONE line newbie168 Shell Programming and Scripting 2 09-27-2005 05:02 AM
perl question - removing line from input file reggiej Shell Programming and Scripting 3 06-07-2005 01:45 PM
read a file as input and pass each line to another script sajjad02 Shell Programming and Scripting 0 09-24-2004 11:13 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 12-16-2005
2reperry 2reperry is offline
Registered User
  
 

Join Date: Dec 2005
Posts: 15
sed not outputting last line of input file

I am using sed for a simple substitution (see command syntax below). Everything works fine except that the last line of the input file does not get written to the output file. Has anyone ever seen this and know of way to force the last line to be written?

I don't know if it's playing a part in this or not, but, each input line can be up to 1600 characters long. All of the lines in the file, with the exception of the last one, are output regardless of whether a substitution was needed or done, which is the expected result.

Command(s) used
-----------------
sed 's/:60/:00/g' < inputfile > outputfile
or
sed '1,$ s/:60/:00/g' < inputfile > outputfile

Last edited by 2reperry; 12-16-2005 at 10:49 AM..
  #2 (permalink)  
Old 12-16-2005
Perderabo's Avatar
Perderabo Perderabo is offline Forum Staff  
Unix Daemon
  
 

Join Date: Aug 2001
Location: Ashburn, Virginia
Posts: 9,111
My guess: last character of file is not a newline character. sed operates on lines not strings and lines must end with a newline character.
  #3 (permalink)  
Old 12-16-2005
2reperry 2reperry is offline
Registered User
  
 

Join Date: Dec 2005
Posts: 15
BINGO! I did a hex dump of the file and found that all of the records except the last one have a linefeed.

Any ideas on how to get a linefeed on this last record prior to running the sed command?
  #4 (permalink)  
Old 12-16-2005
Perderabo's Avatar
Perderabo Perderabo is offline Forum Staff  
Unix Daemon
  
 

Join Date: Aug 2001
Location: Ashburn, Virginia
Posts: 9,111
echo >> datafile
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 08:32 AM.


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