Until now, you read files that were already there. Now you will make your own.
touch makes an empty file at each path that you give it:
text
learner@tidepool:~$ touch list.txt
learner@tidepool:~$ ls -l list.txt
-rw-r--r-- 1 learner learner 0 Oct 12 09:14 list.txtThe size is 0. The file exists, but it is empty. The chapter "Find and Edit Files" shows how to put text in a file.
More than one file
Give touch more than one path. It makes one file for each:
text
learner@tidepool:~$ touch monday.txt tuesday.txt wednesday.txtThe paths can be relative or absolute.
A file that already exists
touch list.txtthe path does not exist
A new, empty file0 bytes
touch prices.txtthe path exists
The time of the last change is nowthe text stays the same
touch never changes the text in a file. With ls -lt, a file that you touched moves to the top of the list.
The directory must exist
touch makes files, not directories. Each directory in the path must exist:
text
learner@tidepool:~$ touch logs/today.txt
touch: cannot touch 'logs/today.txt': No such file or directoryThe next lesson shows how to make a directory.