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 -00read input in paragraph mode- see http://perldoc.perl.org/perlrun.html#command-switches more info ,
-peoptions - use
perl -i -00 -peinplace editing
- see http://perldoc.perl.org/perlrun.html#command-switches more info ,
s/\n(?!$)/ /greplace newlines except 1 blank line space
Comments
Post a Comment