touch

Create new empty file

Supplementary instructions

touch command has two functions: one is used to update the time tags of existing files to the current system time (default mode), and their data will be retained intact; the other is used to create new empty file.

grammar

touch(option)(parameter)

Options

-a: or --time=atime or --time=access or --time=use only change the access time;
-c: or --no-create does not create any files;
-d: <time date> uses the specified date and time instead of the current time;
-f: This parameter will be ignored and will not be processed. It is only responsible for solving the compatibility problem of the BSD version of the touch command;
-m: or --time=mtime or --time=modify only change the change time;
-r: <Reference file or directory> Set the date and time of the specified file or directory to be the same as the date and time of the reference file or directory;
-t: <date time> uses the specified date and time instead of the current time;
--help: online help;
--version: Display version information.

Parameters

File: Specify a list of files to set time attributes for.

Example

touch ex2

Create an empty file ex2 in the current directory, and then use the ls -l command to find that the size of file ex2 is 0, indicating that it is an empty file.

Create files in batches

touch file{1..5}.txt

Create job1.md file and write job 1

echo "job 1" > job1.md