1

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?

closed as off-topic by lenik, syb0rg, RPiAwesomeness, Butters, Impulss Mar 6 '14 at 5:42

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This question does not appear to be specific to the Raspberry Pi within the scope defined in the help center." – lenik, syb0rg, RPiAwesomeness, Butters, Impulss
If this question can be reworded to fit the rules in the help center, please edit the question.

  • Is there any way someone could move this question to the right topic, as it appears to be Off-Topic here? – Diego Mar 10 '14 at 12:59
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
1

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.