Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Bourne Shell echo Cmd and Escape Characters 1

Status
Not open for further replies.

Michael42

Programmer
Oct 8, 2001
1,454
US
Hello,

On Sun Solaris 8 using the Bourne shell I am testing some simple escape characters. In trying to use a new line escape character (\n) it does not seem to work. The below code outputs both lines on one line.

Code:
echo "This is line one.\nThis is line two."

What can you recommend?

Thanks,

Michael42
 
And this ?
/bin/echo "This is line one.\nThis is line two."

Anyway:
man sh
man echo

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
PHV,

That was it! :) I did a "which" on echo and it gave me: /usr/ucb/echo

When I used the full path to echo in the bin directory it worked!

Though I have #!/bin/sh as the first line in my Bourne shell scripts, assuming the user's PATH variable may or may not have this, is there a way to instruct a Bourne shell script to look in /bin for all files first?

Thanks,

Michael42
 
PATH=/bin:$PATH

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
If your script is using the Korn shell, try [tt]print[/tt] instead of [tt]echo[/tt].

Also, this should work too...
Code:
echo "This is line one.
This is line two."
Hope this helps.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top