Difference between revisions of "sed delete newline"

From thelinuxwiki
Jump to: navigation, search
(Created page with " example of sed failing to remove newline... $ '''printf "foo\nbar\n" | sed 's/\n//'''' foo bar solution is to pass sed the -z or --null-data option to separate lines by N...")
 

Latest revision as of 18:53, 2 April 2024

example of sed failing to remove newline...

$ printf "foo\nbar\n" | sed 's/\n//'
foo
bar

solution is to pass sed the -z or --null-data option to separate lines by NUL characters

$ printf "foo\nbar\n" | sed -z 's/\n//'
foobar