Create a Text File from Linux Command Line

Burdette Lamar - May 7 '19 - - Dev Community

Here are some ways I can create a text file from the Linux command line.

cat

Command cat with no source file specified reads from stdin. So I can type this (ending with Ctrl-D):

$ cat > t.txt
Foo
Bar
Baz

echo

Command echo has option -e, which enables interpretation of backslash escapes. So I can type this:

$ echo -e "Foo\nBar\nBaz\n" > t.txt

touch

And finally, if I don't need content in the file, I can just type:

touch t.txt
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Terabox Video Player