I have executed below commandcat /proc/loadavg && dateActual Result:0.00 0.00 0.00 1/803 26256Fri Aug 26 09:00:56 EEST 2016Expected Result:0.00 0.00 0.00 1/803 26256 @@ Fri Aug 26 09:00:56 EEST 2016I have tried sed and tr , but didn't work.cat /proc/loadavg && date | sed 's/\n/ @@ /g'cat /proc/loadavg && date | tr '\n' ' @@ 'Any idea, what I am missing?
How to wrap two line into single line with delimiter
shell;text processing
Your best bet is to use printf. You have two strings and you want to output them with some additional formatting.  That's exactly what printf does.$ printf %s @@ %s\n $(cat /proc/loadavg) $(date)Your tr attempt does not work since tr modifies characters, not words. You could use it to replace the newlines with one single character though:$ ( cat /proc/loadavg; date ) | tr '\n' '@'... but it doesn't do quite what you need.Your sed attempt does not work since the newline is stripped from the input to sed (i.e. sed -n '/\n/p' inputfile would never print anything).You could still do it with sed if you read the second line (from date) with the N editing command while editing the first line (which will place a newline between them):$ ( cat /proc/loadavg; date ) | sed 'N;s/\n/ @@ /'... but I would personally prefer the printf solution.