Creating a File Quickly

You can quickly create an empty file (for later editing) using the touch command:

$ touch newfile

or the echo -n command (see File Properties):[9]

$ echo -n > newfile2

or write data into a new file by redirecting the output of a program (see Input/output redirection):

$ echo anything at all > newfile

[9] The -n option prevents a newline character from being written to the file, making it truly empty.

Get Linux Pocket Guide, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.