To update the timestamps of a file in Bash, you can use the touch command. This command will change the last modified and last accessed times of the specified file(s) to the current time.
Example:
touch filename.txt
Explanation:
- This command updates the timestamps of
filename.txtto the current date and time. - If the file does not exist, it will create an empty file with that name.
Updating Multiple Files:
You can also update multiple files at once:
touch file1.txt file2.txt file3.txt
If you need to set a specific timestamp instead of the current time, you can use the -t option:
touch -t 202301011200 filename.txt
This sets the timestamp to January 1, 2023, at 12:00 PM.
Let me know if you have any more questions!
