The UNIX and Linux Forums  

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
Print Full record and substring in that record ukatru UNIX for Advanced & Expert Users 1 09-19-2008 03:32 PM
how to read record by record from a file in unix raoscb UNIX for Dummies Questions & Answers 1 05-16-2008 03:30 AM
Script to search a bad record in a file then put the record in the bad file shilendrajadon Shell Programming and Scripting 2 12-28-2007 07:02 AM
Script to search a bad record in a file then put the record in the bad file shilendrajadon UNIX for Advanced & Expert Users 1 12-28-2007 07:00 AM
splitting a record and adding a record to a file rsolap Shell Programming and Scripting 1 08-13-2007 10:58 AM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 10-07-2008
Dave Miller's Avatar
Registered User
 

Join Date: Dec 2007
Location: Northern NJ, USA
Posts: 150
End of record markers

I have a file with thousands of 80 character records.

Unfortunately, there are no end of record characters, so any normal script commands that I've tried will process the entire file as one record.

I.E. If I use grep to find the record that contains some specific value, I either get nothing if it's not found, or the entire file, regardless of how many times the string exists. Obviously, I only want the 80 character records that have the string I'm looking for.


How can I convert the file to be true 80 character records so I can use normal script commands?

Thanks
Reply With Quote
Forum Sponsor
  #2  
Old 10-07-2008
Ikon's Avatar
Registered User
 

Join Date: Jul 2008
Location: Phoenix, Arizona
Posts: 407
try this:

Code:
sed 's/\(.\{80\}\)/\1\n/g' your.log > yournew.log
Reply With Quote
  #3  
Old 10-07-2008
era era is offline
Herder of Useless Cats
 

Join Date: Mar 2008
Location: /there/is/only/bin/sh
Posts: 3,650
Or just fold -w 80 file
Reply With Quote
  #4  
Old 10-07-2008
Dave Miller's Avatar
Registered User
 

Join Date: Dec 2007
Location: Northern NJ, USA
Posts: 150
fold

Yeah, that's the ticket. I just knew there'd be a simple way to do this.

And, bonus... I can leave out the -w 80 since that's the default!


Thanks.
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 09:55 PM.


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

Content Relevant URLs by vBSEO 3.2.0