This question already has an answer here:
- Can sed replace new line characters? 7 answers
I've got text with whitespace (including a newline) that I need to replace. I'd like to use
sed, but AIX doesn't seem to support the answers to
sed newline questions I found. The version of bash I'm using is "GNU bash, version 3.00.16(1)-release (powerpc-ibm-aix5.1)"
If I run a command that outputs a bunch of pairs of lines of text like:
alias: aliasname 10:00:00:00:00:00:00:00
What is the best way to make it one line for each? If I use
ssh user@system command | tr '\n' ' ', it replaces both newlines, and I need to keep the last one or else the output goes into a single line.
Edit: what I've tried so far is:
| sed -e ':1' -e 'N' -e '$!b1' -e 's/\n/ /g'which replaces all the newlines, putting the entire output stream into a single line.
| while read i; do printf "%s " $i; done; echowhich also replaces all the newlines
| tr -d '\n'and
| tr -d '\n'; echo, which still replace all newlines, however the echo adds one back at the last command.