The Linux touch Command: Create or Update Timestamps
touch creates empty files or updates timestamps on existing files.
Basic Usage
Create file
touch newfile.txtCreates empty file.
Update timestamp
touch existing.txtUpdates mtime to now.
Options
-a— Change atime only-m— Change mtime only-c— Don't create (just update)-d TIME— Set time-r FILE— Use timestamp from reference file
Examples
Don't create
touch -c nonexistent.txtDoes nothing (no error either).
Use reference time
touch -r otherfile.txt newfile.txtCopies timestamp from otherfile.
Set specific time
touch -d "2024-01-01 00:00" file.txtSet exact timestamp.
