LinuxQuestions.org
Visit Jeremy's Blog.
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 08-27-2008, 03:58 AM   #1
Junior_DBA
LQ Newbie
 
Registered: Aug 2008
Posts: 25

Rep: Reputation: 15
how to print all at one line


Hi all. Super newbie questionI didn't find out it in the web.

How to print this all on one line

echo "dog "
echo "bytes "
echo "hard "

I want:
dog bytes hard


Thanks.
 
Old 08-27-2008, 04:05 AM   #2
matthewg42
Senior Member
 
Registered: Oct 2003
Location: UK
Distribution: Kubuntu 12.10 (using awesome wm though)
Posts: 3,530

Rep: Reputation: 63
Code:
echo "dog bytes hard "
?
 
Old 08-27-2008, 04:10 AM   #3
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 670Reputation: 670Reputation: 670Reputation: 670Reputation: 670Reputation: 670
Read the help for echo:enter "help echo" in bash. Look at the -n option.

Also look at -e with \c in the string.
 
Old 08-27-2008, 04:18 AM   #4
ghostdog74
Senior Member
 
Registered: Aug 2006
Posts: 2,697
Blog Entries: 5

Rep: Reputation: 244Reputation: 244Reputation: 244
the more portable way : printf
Code:
printf "%s" "dogs byte hard"
 
Old 08-27-2008, 04:56 AM   #5
Junior_DBA
LQ Newbie
 
Registered: Aug 2008
Posts: 25

Original Poster
Rep: Reputation: 15
Quote:
echo "dog bytes hard "

?
I have
echo "dog "
#some actions
echo "bytes "
#some actions
echo "hard "

Quote:
Also look at -e with \c in the string.
Thanks! This works but I am getting:
dog bytes hard]
 
Old 08-27-2008, 05:42 AM   #6
arizonagroovejet
Senior Member
 
Registered: Jun 2005
Location: England
Distribution: openSUSE, Fedora, CentOS
Posts: 1,078

Rep: Reputation: 195Reputation: 195
How about using the -n option which means "do not output the trailing newline"

Code:
mike@continuity:~$ echo -n "dog"; date > /tmp/blah;echo -n " bytes";date >> /tmp/blah; echo  " hard"
dog bytes hard
mike@continuity:~$ cat /tmp/blah
Wed Aug 27 10:41:49 IST 2008
Wed Aug 27 10:41:49 IST 2008
 
  


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
Print from a line number hammertime1983 Linux - Newbie 3 08-20-2007 08:06 AM
Shell scripting: print first line and last line only Micro420 Programming 5 05-20-2007 07:26 PM
print the line of following line no suchi_s Programming 6 09-08-2004 09:22 AM
Print line for line pk21 Programming 12 03-17-2004 05:12 AM
Print from command line cli_man Linux - Newbie 4 06-16-2002 10:57 PM


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

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