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
how to read record by record from a file in unix raoscb UNIX for Dummies Questions & Answers 1 05-16-2008 06:30 AM
Remove First and Last Record from a file ravikuc UNIX for Dummies Questions & Answers 1 10-11-2007 03:35 AM
splitting a record and adding a record to a file rsolap Shell Programming and Scripting 1 08-13-2007 01:58 PM
Usiung last record of file using 'sed' command Roopanwita Shell Programming and Scripting 5 06-29-2007 02:25 AM
remove duplicated xml record in a file under unix happyv Shell Programming and Scripting 8 09-20-2006 01:36 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 01-09-2007
mheinen mheinen is offline
Registered User
  
 

Join Date: Jan 2007
Posts: 6
command to remove last record on file

Hi,
First time on the forum. I have converted some files using the Unix to DOS command but need to strip off the last record that is generated from this conversion that contains just a ^Z. Is there any command that would accomplish this without having to do stream editing?
  #2 (permalink)  
Old 01-09-2007
Glenn Arndt's Avatar
Glenn Arndt Glenn Arndt is offline Forum Advisor  
Anomalous Lurker
  
 

Join Date: Feb 2006
Location: Indianapolis, IN
Posts: 255
Without stream editing? I don't understand that requirement.

Have you tried:
Code:
sed '$d' myfile
  #3 (permalink)  
Old 01-09-2007
mheinen mheinen is offline
Registered User
  
 

Join Date: Jan 2007
Posts: 6
You put me on the right track. I ended up using sed and successfully stripped off the ^Z at the end of the file by using:

sed '/^Z/d' myfile|cat > newfile

Thanks for the help.
  #4 (permalink)  
Old 01-09-2007
Glenn Arndt's Avatar
Glenn Arndt Glenn Arndt is offline Forum Advisor  
Anomalous Lurker
  
 

Join Date: Feb 2006
Location: Indianapolis, IN
Posts: 255
What is the 'cat' for? Why not just:
Code:
sed '/^Z/d' myfile > newfile
?
  #5 (permalink)  
Old 01-09-2007
mheinen mheinen is offline
Registered User
  
 

Join Date: Jan 2007
Posts: 6
Well, I'm constantly learning that there's multiple ways of doing things in the Unix world! I removed the 'cat' code from my script and ran it again redirecting the output to the new file name and it works the same way as
the other logic that I had used. Thanks again for the fast response and help.
Sponsored Links
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 11:41 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language translation by Google.
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