PDA

View Full Version : [SOLVED] Append command output to end of line and not to newline



Gen2ly
September 7th, 2009, 02:36 PM
I can think of a couple ways to do this but neither would be real elegant. I got two commands and I'd like their output to go onto one line. This is probably real easy but I've never seen it before so I'd appreciate the help. The lines I got are:


xset -q | grep -o "Standby: [0-9]*[0-9] " | sed -e "s/Standby: //" > /tmp/dpmsvalues
xset -q | grep -o "Off: [0-9]*[0-9]" | sed -e "s/Off: //" >> /tmp/dmpsvalues

Obviously though, this is going to write the output to two separate lines. Is there a way to do this without having to edit the output file?

Arndt
September 7th, 2009, 03:12 PM
I can think of a couple ways to do this but neither would be real elegant. I got two commands and I'd like their output to go onto one line. This is probably real easy but I've never seen it before so I'd appreciate the help. The lines I got are:


xset -q | grep -o "Standby: [0-9]*[0-9] " | sed -e "s/Standby: //" > /tmp/dpmsvalues
xset -q | grep -o "Off: [0-9]*[0-9]" | sed -e "s/Off: //" >> /tmp/dmpsvalues

Obviously though, this is going to write the output to two separate lines. Is there a way to do this without having to edit the output file?

You can use some ideas from here: http://linux.dsplabs.com.au/rmnl-remove-new-line-characters-tr-awk-perl-sed-c-cpp-bash-python-xargs-ghc-ghci-haskell-sam-ssam-p65/

Gen2ly
September 7th, 2009, 03:37 PM
Ha, just what I needed. 'echo -n', will do the trick. Thanks Arndt.