Creating Files with Content

Learn how to create files with content.

The touch command creates blank text files, and as we already know, weu can capture the output of programs to a text file by redirecting the program’s output to a file. Let’s review this by creating a new text file in the current directory that contains the text “Hello, World.” Use the echo command to print out the text and then redirect it to a file.

Using echo to create a file

$ echo 'Hello, World' > hello.txt

Get hands-on with 1400+ tech skills courses.