O'Reilly logo

Linux and Unix Shell Programming by David Tansley

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

5.1. echo

Use echo to display lines of text or variables or to direct strings into files. The general format is:

echo string 

The echo command comes with many features, but the most useful ones are as follows:

\c do not go to the next line
\f formfeed
\t tab
\n newline

To keep the prompt at the end of your string use:

						$ echo  "What is your name :\c" 
$ read name
					

The output from the above would display:

						What is your name :
						

where ‘’ is the cursor.

To echo a string and let the cursor go to the next line use:

						$ echo "The red pen ran out of ink" ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required