This post is a quick ref on the linux touch command. All the examples have been tested on Linux.
This command is used to update the access and modification times of files.
touch [option] file_name(s) touch file1 file2 file3
# touch /tmp/file # ls -l /tmp/file rw-r--r-- 1 charlybr charlybr 0 Sep 10 16:13 /tmp/file
# ls -l /tmp/file rw-r--r-- 1 charlybr charlybr 0 Sep 10 16:13 /tmp/file # touch /tmp/file # ls -l /tmp/file rw-r--r-- 1 charlybr charlybr 0 Sep 10 16:14 /tmp/file
# touch -t 09091842 /tmp/file # ls -l /tmp/file -rw-r--r-- 1 charlybr charlybr 0 Sep 9 18:42 /tmp/file
# touch -d '9 Sep' /tmp/file # ls -l /tmp/file -rw-r--r-- 1 charlybr charlybr 0 Sep 9 00:00 /tmp/file # touch -d '9 Sep 2008 13:14' /tmp/file # ls -l /tmp/file -rw-r--r-- 1 charlybr charlybr 0 Sep 9 13:14 /tmp/file
This entry was written by , posted on September 11, 2008 at 7:30 am, filed under Command line and tagged coretutils, shell. Leave a comment or view the discussion at the permalink.