In Linux shell bash script, how to print to a file at the same line?
few options there:
echo -n foo bar
It's simple, but may not work on some old UNIX systems like HP-UX or SunOS. Instead the "-n" will be printed as well as the rest of the arguments followed by new line.echo -e "foo bar\c"
. The\c
has meaning: "produce no further output". I don't like this solution personally, but some UNIX wizards use it.printf %b "foo bar"
I like this solution the most. It's quite portable as well flexible.