![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | 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 !! |
|
|
||||
| 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 |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
||||
|
||||
|
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 |
| Forum Sponsor | ||
|
|
|
#2
|
||||
|
||||
|
try this:
Code:
sed 's/\(.\{80\}\)/\1\n/g' your.log > yournew.log
|
|
#3
|
|||
|
|||
|
Or just fold -w 80 file
|
|
#4
|
||||
|
||||
|
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. |
||||
| Google The UNIX and Linux Forums |