The touch command is used to create an empty file or to update the access and modification times of an existing file.
touch [OPTION]... FILE...
-a: Change only the access time.-m: Change only the modification time.-c or --no-create: Do not create any files.-d or --date=STRING: Parse STRING and use it instead of the current time.-r or --reference=FILE: Use this file’s times instead of the current time.-t STAMP: Use [[CC]YY]MMDDhhmm[.ss] instead of the current time.Create an empty file:
touch filename.txt
Update the access and modification times of an existing file:
touch existingfile.txt
Change only the access time:
touch -a filename.txt
Change only the modification time:
touch -m filename.txt
Do not create any files if they do not exist:
touch -c filename.txt
Use a specific date and time:
touch -d "2023-01-01 12:34:56" filename.txt
Use the times from another file:
touch -r referencefile.txt filename.txt
Use a specific timestamp:
touch -t 202301011234.56 filename.txt