I am wondering how to pipe the outputs from several commands (4 commands to be precise) into one single line in a text-file. For no I have the following code that pipes the output into 4 different lines

($skriptdate && $skripttime; && eval $temp; && eval $humid;) >> /home/pi/test12345.txt

What do I need to do to make it write on one single line?

  • Is there any way someone could move this question to the right topic, as it appears to be Off-Topic here?
    – Diego
    Commented Mar 10, 2014 at 12:59

2 Answers 2


@goldilocks approach is good!

i would advise doing that with

echo -n $( your commands ) >> whatever.txt

or in pipe mode

your commands | xargs echo -n >> whatever.txt

prinft is killing the whitespaces \s .. i really dont know why.. maybe anybody got an explanation for this behavior?

your commands | xargs printf %s >> whatever.txt
printf %s $( your commands ) >> whatever.txt

You could pipe through tr:

(your commands) | tr '\n' ' ' >> whatever.txt

This actually replaces the newline (\n) with a space. If you just want to remove the newline, use tr -d '\n' instead.

See man tr for details.

Not the answer you're looking for? Browse other questions tagged or ask your own question.