You can create files at the command line using several different commands. The Touch command (touch) creates empty files. You can open these files in a text editor or similar program to type content. You can also use the Concatenate command (cat) to create files by taking the input you provide to the shell and redirecting it as output to a new file. For information about redirecting output, see "Redirecting input and output." The cat command can also combine several files into one new file.
You can use command options with the touch and cat commands. For a list of command options, see the Manual pages for each command.
To create a file using the touch command
1. At the command line, type,
touch [options] <filename>...
2. Press ENTER.
To create a file using the cat command
1. At the command line, type,
cat > <filename>
2. Type the contents of the file.
3. Press ENTER.
4. Press CTRL + D to return to the command line.
To create a new file by combining files
1. At the command line, type,
cat [options] <filename>... > <newfile>
2. Press ENTER.
Notes
The ellipsis indicates that you can type multiple filenames; for example, cat [options] <file1> <file2> <file3>.
You can open the <newfile> in a text editor, or type cat <newfile>, and press ENTER, to view the file output.
Do not include the brackets in the command line text. For information about notation conventions for commands, see "Using notation conventions for Linux commands."