June 2012
Beginner
227 pages
5h 43m
English
You can quickly create an empty file (for later editing) using the
touch command, providing a filename
that does not exist (see File Properties):
➜ touch newfileAnother quick technique uses the echo command with the -n option, redirecting its output to a new
file. This option prevents a newline character from being echoed, making
the file truly empty:
➜ echo -n > newfile2You can also write data into a new file by redirecting the output of a program (see Input/output redirection):
➜ echo anything at all > newfileIf you accidentally provide the name of an existing file, touch will preserve it but redirecting echo
will erase its contents. So be careful!
Read now
Unlock full access