LinuxQuestions.org
Latest LQ Deal: Linux Power User Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 07-21-2010, 05:18 AM   #1
elainelaw
Member
 
Registered: Jan 2008
Posts: 258

Rep: Reputation: 30
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
 
Old 07-21-2010, 05:57 AM   #2
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.9, Centos 7.3
Posts: 17,417

Rep: Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397
http://tldp.org/LDP/Bash-Beginners-G...html#tab_08_01
 
Old 07-21-2010, 06:02 AM   #3
karthiksharu
LQ Newbie
 
Registered: May 2009
Posts: 15

Rep: Reputation: 0
Quote:
Originally Posted by chrism01 View Post

ya ..Chris is correct ..

printf "test1" > /tmp/file
printf "test2" >> /tmp/file
 
Old 07-21-2010, 06:08 AM   #4
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.9, Centos 7.3
Posts: 17,417

Rep: Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397
Actually, I'm pointing at the escape codes for 'echo' ; specifically \c means don't print a newline.
 
Old 07-21-2010, 08:14 AM   #5
MTK358
LQ 5k Club
 
Registered: Sep 2009
Posts: 6,443
Blog Entries: 3

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


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
When I use xargs with echo, why does the output contain an extra space? web_janitor Linux - General 2 08-20-2009 05:18 PM
change echo default setting to -e in Etch fangorn Debian 1 03-13-2007 10:42 AM
How to change listening port of echo server [RH9]? immer Linux - Networking 5 11-29-2003 05:30 PM
Using echo to output a string to a file with forward slashs chrisk5527 Linux - General 15 06-21-2003 03:04 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 03:47 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration