Hello, I have read a few threads on this subject and tried a few things out, but still come up short.
There was one good example, then the last reply was something to the effect of 'Use Sed' & 'Read a book'...
Well I read a bunch of online tutorials on sed, awk, tr, but still can't get the right results.
input file>
1234|hello there buddy|8beers|2008-01-01
1234|this is a nice party, don't you think?|2champaigns|2008-01-01
1234|there are two things:
thing 1 & thing2|36shots|2008-01-01
desired output>
1234|hello there buddy|8beers|2008-01-01
1234|this is a nice party, don't you think?|2champaigns|2008-01-01
1234|there are two things: thing1 & thing2|36shots|2008-01-01
The closest I could get was with this command->
nawk '{ if ( $0 ~ /1234/ && NR > 1 ) { printf "\n"; } printf $0; } END { printf "\n"; }' party.txt > dump.txt
But after line 460664 I received an error:
awk: There are not enough parameters in printf statement ...
The only thing that looks different about that line is there is an ampersand '&' in one of the fields.
I tailed the rest of the file into the the nawk and it puked after another 1600 lines. I tried a couple more times and it still keeps running out of steam before the millionth row.
The other way I tried was ghetto style:
tr -d '\n' to remove all the carriage returns, then
sed s/2008-01-01/2008-01-01\n/g <party.txt> dump.txt
but sed pukes with a sed: Memory allocation failed after about a minute.
Ideally, I need a one liner...
Any suggestions?
Thanks.