Sunday, 15 June 2014

bash - Merge two blank lines into one -



bash - Merge two blank lines into one -

i looking solution of turning file file b, requires merging 2 blank lines one.

file-a:

// comment 1 // comment 2 // comment 3 // comment 4 // comment 5

file-b:

// comment 1 // comment 2 // comment 3 // comment 4 // comment 5

from this post, know how delete empty lines, wondering how merge 2 consecutive blank lines one.

ps: blank means empty or there might tab or space in line.

sed -r 's/^\s+$//' infile | cat -s > outfile

sed removes whitespace on blank line. -s alternative cat squeezes consecutive blank lines one.

bash sed

No comments:

Post a Comment