Create a new file:
touch new_file.txt
This will create an empty file named new_file.txt
in the current directory.
Update the time stamp of an existing file:
touch existing_file.txt
This will update the access and modification time stamps of the file named existing_file.txt
to the current time.
Update the time stamp of a file with a specified time stamp:
touch -t 202201011200 existing_file.txt
This will update the access and modification time stamps of the file named existing_file.txt
with the specified time stamp 202201011200
.
Update the time stamp of a file with the time stamp of another file:
touch -r reference_file.txt existing_file.txt
This will update the access and modification time stamps of the file named existing_file.txt
with the time stamp of the file named reference_file.txt
.
Modify the modification time of a file:
touch -m existing_file.txt
This will only update the modification time stamp of the file named existing_file.txt
to the current time, without updating the access time stamp.