previous contents up next

Unix for Advanced Users

6. Manipulating Files

6.1. Creating Files

6.1.4. echo

The echo command can be used in conjunction with I/O redirects to create files. You can simply type:

echo "put me in a file" > file

and it will save the line of text into the file we have called file

Here's a practical use of this method. To forward your mail on a Unix system, you place a .forward file in your home directory. The .forward file should simply contain the mail address you would like all incoming mail to be redirected. In this case you can use an elegant one line solution without having to invoke an editor.

echo me@my.new.address > .forward

previous contents up next