Collapsing 4 lines into 1
I want to collapse 4 lines into 1 line, between { and }.
Using this sed regular expression, it's only collapsing the first line. Any tips would be warmly welcomed. Code:
$ egrep -v '({|})' file | sed 'N;s/\n/ /' Code:
"weather": "terrible", "Food": "biscuits", "Hotel": "Fawlty Towers", "country": "United Kingdom" Code:
{ |
Quote:
1) replace all instances of newline with blank 2) replace all instances of } with blank 3) replace all instances of { with newline Code:
tr "\n}{" " \n" <$InFile >$OutFile |
Code:
awk '/{/{next}/}/{$0=RS}ORS="\0"' file |
Same idea
Code:
perl -pe 's/{?\n|}//' file |
All times are GMT -5. The time now is 11:57 AM. |