string - How can join consecutive non-empty lines using sed/awk? -
how can join consecutive non-empty lines single lines using sed or awk? example given of trying do.
input:
aaa ff gg bbb eee eee ss gg dd aaa ff gg bbb eee eee ss gg dd aaa ff gg bbb eee eee ss gg dd
converts
aaa ff gg bbb eee eee ss gg dd aaa ff gg bbb eee eee ss gg dd aaa ff gg bbb eee eee ss gg dd
if perl
okay:
$ perl -00 -pe 's/\n(?!$)/ /g' ip.txt aaa ff gg bbb eee eee ss gg dd aaa ff gg bbb eee eee ss gg dd aaa ff gg bbb eee eee ss gg dd
-00
read input in paragraph mode- see http://perldoc.perl.org/perlrun.html#command-switches more info ,
-pe
options - use
perl -i -00 -pe
inplace editing
- see http://perldoc.perl.org/perlrun.html#command-switches more info ,
s/\n(?!$)/ /g
replace newlines except 1 blank line space
Comments
Post a Comment