[Sed] Replace newline (\n) to different symbol
sed ':a; N; $!ba; s/\n/=""\n/g' 1.txt
1. create a label via :a
2. append the current and next line to the pattern space via N
3. if we are before the last line, branch to the created label $!ba ($! means not to do it on the last line (as there should be one final newline)).
4. finally the substitution replaces every newline with a space on the pattern space (which is the whole file).
Reference:
0 意見:
張貼留言