Creating Files

In Creating and Reading Files, you learned how to use the echo command and redirection to create files. This is one of many ways to create files on the command line. Let’s look at a few alternatives.

If you only need to create an empty file, you can use the touch command. This command is designed to update the timestamp of a file. It’s common for programs to watch a file for changes and then react to those changes by executing a process. For example, you might have a process that runs tests whenever a file changes, but you don’t actually want to open the file and make a change. You can use touch to modify the file without actually changing the contents. This would then trigger the program or process monitoring the file.

However, ...

Get Small, Sharp Software Tools 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.