LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Change echo output (https://www.linuxquestions.org/questions/linux-newbie-8/change-echo-output-821208/)

elainelaw 07-21-2010 04:18 AM

Change echo output
 
I have the below command

echo "test1" > /tmp/file
echo "test2" >> /tmp/file

The output of /tmp/file is

test1
test2

If I want the output is in same line as below , can advise what can i do ? thx

test1 test2

chrism01 07-21-2010 04:57 AM

http://tldp.org/LDP/Bash-Beginners-G...html#tab_08_01

karthiksharu 07-21-2010 05:02 AM

Quote:

Originally Posted by chrism01 (Post 4040473)


ya ..Chris is correct ..

printf "test1" > /tmp/file
printf "test2" >> /tmp/file

chrism01 07-21-2010 05:08 AM

Actually, I'm pointing at the escape codes for 'echo' ; specifically \c means don't print a newline.

MTK358 07-21-2010 07:14 AM

You should use the "-n" option for echo, which tells it not to stick a newline on the end.


All times are GMT -5. The time now is 08:46 AM.