Exploring touch - Linux Commands
What is a touch command?
In Linux, the touch command is used to create empty files and update the access and modification timestamps of existing files. It is a versatile command with several options, but its primary purpose is to update the timestamp of a file or create a new file if it doesn’t exist.
Here’s the basic syntax of the touch command:
touch [options] file1 file2 file3-
cor-no-create:- This is to check the specific file. If the file is present, it updates the access, modification, and change time, however, if the file doesn’t exist, it takes no action to create a new file.
Terminal window touch -c filename -
tor-time:- The
toption allows you to specify a custom timestamp for the file’s access and modification times. This can be useful in certain scripting or automation scenarios.
Terminal window touch -t YYYYMMDDhhmm.ss filename# Example: Set the timestamp to January 31, 2023, 14:30:00# touch -t 202301311430.00 filename - The
-
aor-time=access:- The
aoption is used to change only the access time of a file, leaving the modification time unchanged.
Terminal window touch -a filename - The
-
mor-time=modify:- The
moption is used to change only the modification time of a file, leaving the access time unchanged.
Terminal window touch -m filename - The
If you want to learn more about the touch command and its options directly in the terminal, you can use the man command for the manual.
man touchResources
Thank you
Thank you for your time and for reading this!