LinuxQuestions.org
Review your favorite Linux distribution.
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 02-03-2006, 08:07 AM   #1
suneel
LQ Newbie
 
Registered: Nov 2005
Location: Hyderabad
Distribution: Fedora
Posts: 5

Rep: Reputation: 0
Question echo \n not working.


Hi,
I am trying to learn shell scripting. I have fedore 4. I tried the following statement in the bash shell.
echo hello \n world.
But I got the output as
hello n world
I expected \n to work as a new line character. Am I doing some thing wrong? Pls help in getting new line character.

Thanks,
Suneel.
 
Old 02-03-2006, 08:38 AM   #2
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 11,520

Rep: Reputation: 1502Reputation: 1502Reputation: 1502Reputation: 1502Reputation: 1502Reputation: 1502Reputation: 1502Reputation: 1502Reputation: 1502Reputation: 1502Reputation: 1502
This should do the trick:
Code:
echo -e "hello\nworld"
 
Old 02-03-2006, 08:39 AM   #3
pokemaster
Member
 
Registered: Apr 2005
Location: Massachusetts, USA
Distribution: debian,ubuntu,slackware
Posts: 110

Rep: Reputation: 17
EDIT --bathory posted while I was typing and, indeed proved me wrong -- I'll leave my post for the reference.

unfortunately -- not gonna happen (AFAIK someone correct me if I'm wrong)
Code:
echo hello
echo world
will do what you want. By default, echo tacks on a newline. If you want to disable this temporarily, i.e.
Code:
echo -n hel
echo lo
echo world
will do the same as the first segment.

Last edited by pokemaster; 02-03-2006 at 08:41 AM.
 
  


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
Echo onelung02 Slackware 6 08-26-2005 05:50 PM
Kphone echo (echo echo) scabies Linux - Software 0 10-18-2004 03:59 PM
Telnet protocol not working as per RFC for ECHO option kumpt Linux - Networking 0 05-24-2004 02:59 AM
echo $? amaze Linux - General 5 08-15-2003 06:36 AM
Echo /devPrinting doesn't work, echo /usb/lp0 works, Testpage works, Printing doesn't Hegemon Linux - General 3 08-15-2002 02:13 PM


All times are GMT -5. The time now is 03:59 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