Site icon LinuxCommands.site

touch command tutorial in linux/unix with examples and use cases

Linux touch command – change file timestamps

Linux touch command is used to modify the time attributes of a file or directory, including access time and modification time. If the file does not exist, the system will create a new file.

Syntax

 touch [OPTION]... FILE...

Options

Examples & Use Cases

Update file access and modification times

In the following example, we will update the access and modification time of the test.log file to the current time. Of course, the test.log file is an existing file, otherwise a new file named test.log will be created.

 ➜  touch test.log

Create multiple empty files at the same time

In the following example, we will use the touch command to create multiple empty files at the same time. Separate multiple file names with spaces.

 ➜  ~ touch a.log b.log c.log

Exit mobile version