Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

combine lines 2

Status
Not open for further replies.

we2aresame

Technical User
Feb 10, 2003
128
CA
I have a file like this:
{"1","abc","hello",
"yes","w",
"ok","thanks"}
{"good","try","56",
"how are you","45",
"long","th"}
...
I need change it to:

{"1","abc","hello","yes","w","ok","thanks"}
{"good","try","56","how are you","45","long","th"}
...

The file is very huge, I may can only use script to do this. Somebody can give me a hand? thanks.
 
Try something like this:
awk '{buf=buf""$0}/}/{print buf;buf=""}' /path/to/inputfile

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Thanks PHV.
I checked the manual of awk, I couldn't find a "buf". So what's the meaning of "buf=buf"? Thanks.
 
If you have Perl:
cat x | perl -e 'while (<>) { chomp; printf "%s", $_; print "\n" if (/}/); }'
 
buf is simply the name of a variable holding th running stuff to print.
Have you tried my awk script ?

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Thanks PHV, your script is very good solution.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top