sed 개행 문자 제거 (정규식)

OS/리눅스 & 유닉스 2012. 5. 15. 14:23
http://stackoverflow.com/questions/1251999/sed-how-can-i-replace-a-newline-n



sed ':a;N;$!ba;s/\n/ /g' file
  1. :a create a label 'a'
  2. N append the next line to the pattern space
  3. $! if not the last lineba branch (go to) label 'a'
  4. 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

: