|
|||||||
| Forums | Search Forums | Register | Forum Rules | Man Pages | Albums | FAQ | Members | Calendar | Search | Today's Posts | Mark Forums Read |
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
|
|
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
new line in shell script
This may sound elementary question. But how do I add new line in my shell script?
This works: echo '###' This prints \n ### and not ### on a new line... echo "\n ###" |
| Sponsored Links | ||
|
|
#2
|
|||
|
|||
|
Have you tried Code:
echo "" echo "###" |
| Sponsored Links | ||
|
|
#3
|
|||
|
|||
|
hi,
just try echo "\n" |
|
#4
|
|||
|
|||
|
There are different versions of echo, some of which will print a newline when they see \n (and some will only do it when invoked with the -e option). The portable way is to echo nothing, since echo (without options) will always supply a newline. Code:
echo More generally, you might be surprised to learn that strings are allowed to contain newlines. It looks funny, but it can be handy. Code:
echo "foo bar baz" For long sequences of text, you should also consider here documents. Code:
cat <<HERE foo bar baz HERE |
| Sponsored Links | ||
|
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| linux shell script to take variables from two different files line by line | atanubanerji | Shell Programming and Scripting | 4 | 10-13-2011 04:04 AM |
| Shell script to read a text file line by line & process it... | new_to_shell | Shell Programming and Scripting | 8 | 09-13-2011 04:45 AM |
| get the fifth line of a text file into a shell script and trim the line to extract a WORD | venu | Shell Programming and Scripting | 3 | 12-08-2010 08:46 PM |
| how can u read a file line by line in shell script ? | abhigrkist | Shell Programming and Scripting | 4 | 11-08-2010 05:38 PM |
| Shell script to count number of ~ from each line and compare with next line | Ganesh Khandare | Shell Programming and Scripting | 3 | 09-29-2010 04:06 PM |
|
|