sed ':a;N;$!ba;s/\n/ /g'
:a create a label 'a'N append the next line to the pattern space$! if not the last line, ba branch (go to) label 'a's substitute, /\n/ regex for new line, / / by a space, /g global match (as many times as it can)sed will loop through step 1 to 3 until it reach the last line, getting all lines fit in the pattern space where sed will substitute all \n characters
Copied from:
https://stackoverflow.com/questions/1251999/how-can-i-replace-a-newline-n-using-sed
No comments:
Post a Comment