Operating System - HP-UX
1821245 Members
2710 Online
109632 Solutions
New Discussion юеВ

Inserting a newline character in a echo

 
SOLVED
Go to solution
Rui Vilao
Regular Advisor

Inserting a newline character in a echo

Greetings,

I am writing a shell script where I generate a echo of a string.
I want to insert newlines in order to
spread this string over a few lines.

Another question: What is the purpose of using the -p switch in a script:

#!/usr/bin/sh -p

Any help/suggestion is highly appreciated.

TIA.

Kind Regards,

Rui.
"We should never stop learning"_________ rui.vilao@rocketmail.com
5 REPLIES 5
Rainer von Bongartz
Honored Contributor

Re: Inserting a newline character in a echo

# echo "\n\n\n This is a Test \n\n\n"



This is a Test



#

Regards
Rainer
He's a real UNIX Man, sitting in his UNIX LAN making all his UNIX plans for nobody ...
Paula J Frazer-Campbell
Honored Contributor

Re: Inserting a newline character in a echo

Hi

With -P, preserve the physical path when treating symbolic links. cd -P .. changes the working directory to the actual parent directory of the current directory.


Paula
If you can spell SysAdmin then you is one - anon
James R. Ferguson
Acclaimed Contributor
Solution

Re: Inserting a newline character in a echo

Hi Rui:

# echo "Double\n\nspace\n\nthis\n\noutput\n"

Thus, the '\n' constitutes a newline character.

From the man pages for 'sh-posix':

"Disable processing of the $HOME/.profile file and uses the file /etc/suid_profile instead of the ENV file. This mode is on whenever the effective user ID (group ID) is not equal to the real user ID (group ID). Turning this off causes the effective user ID and group ID to be set to the real user ID and group ID."

Regards!

...JRF...
Marco Santerre
Honored Contributor

Re: Inserting a newline character in a echo

an echo "\n" should do the trick for your newline
Cooperation is doing with a smile what you have to do anyhow.
T G Manikandan
Honored Contributor

Re: Inserting a newline character in a echo

echo "\nManikandan \n\n\n"
echo "\n\n"

-p option --bypass the local .profile file.
for the -p option check the man pages of sh-posix.


Thanks