Reputation: 9460
I have a text file whose conntents are this:
Fri Oct 02 19:52:02 +0000 2009 | JeLLz Mamii;) | DopeAssDarLey | my b.i⥠BITCH!! | @_steffhoney lmfao oh Dayum gull inee hihup Walmart en boiy maself sum skoo sepplies
Tue Aug 30 23:29:47 +0000 2011 | Braydon Tyrrell | braydon_tyrrell | westlock. AB. canada | RT @Darkskin: RT @JazmineDukes: @Darkskin Who are you that U have a blue check mark by ur name?? <
I polish shoes at Walmart while pp ...
As can be seen the line 'I polish shoes..' is a part of the second record of Tues Aug 30
. But while processing this file for something, it is taken as a third entirely different record.
I want to be able to merge the 'I polish shoes' line with the line just before it, i.e 'check mark by your name??' Is there a way to do this. This anomaly is present in many of the records in the file. So I need to be able to do it for all such records, so that my output looks something like
Fri Oct 02 19:52:02 +0000 2009 | JeLLz Mamii;) | DopeAssDarLey | my b.i⥠BITCH!! | @_steffhoney lmfao oh Dayum gull inee hihup Walmart en boiy maself sum skoo sepplies
Tue Aug 30 23:29:47 +0000 2011 | Braydon Tyrrell | braydon_tyrrell | westlock. AB. canada | RT @Darkskin: RT @JazmineDukes: @Darkskin Who are you that U have a blue check mark by ur name?? < I polish shoes at Walmart while pp ...
Upvotes: 1
Views: 96
Reputation: 247052
perl -00 -lpe 's/\n//g'
That reads the file a "paragraph" at a time, and removes "interior" newlines.
Upvotes: 0
Reputation: 54532
This will join the next line if it contains a trailing space:
sed '/ $/ N; s/\n//' file.txt
If however there could be multiple lines with trailing spaces, you'll need a loop:
sed -e :a -e '/ $/ { $!N; s/\n//; ta }' file
Results:
Fri Oct 02 19:52:02 +0000 2009 | JeLLz Mamii;) | DopeAssDarLey | my b.i⥠BITCH!! | @_steffhoney lmfao oh Dayum gull inee hihup Walmart en boiy maself sum skoo sepplies
Tue Aug 30 23:29:47 +0000 2011 | Braydon Tyrrell | braydon_tyrrell | westlock. AB. canada | RT @Darkskin: RT @JazmineDukes: @Darkskin Who are you that U have a blue check mark by ur name?? < I polish shoes at Walmart while pp ...
Upvotes: 1
Reputation: 4107
You could try:
awk -v RS='\n\n+' '{ sub(/\n/, "", $0) ; print $0 "\n" }' log.txt
Upvotes: 0