Friday, August 10, 2007

Unix - `touch`,`settime`

Unix,Linux command.

`touch, settime` - change file access and modification times

touch [ -acm ] [ -r ref_file -t time ] file ...
touch [ -acm ] [ date_time ] file ...
settime [ -f ref_file ] file ...

The touch utility sets the access and modification times of each file. The file operand is created if it does not already exist.
The time used can be specified by -t time, by the corresponding time fields of the file referenced by -r ref_file, or by the date_time operand. If none of these are specified, touch uses the current time (the value returned by the time(2) function).
If neither the -a nor -m options are specified, touch updates both the modification and access times.
The settime utility is equivalent to touch -c.
OPTIONS touch The following options are supported for the touch utility:
-a Change the access time of file. Do not change the modification time unless -m is also specified.
-c Do not create a specified file if it does not exist. Do not write any diagnostic messages concerning this condition.
-m Change the modification time of file. Do not change the access time unless -a is also specified.
-r ref_file Use the corresponding times of the file named by ref_file instead of the current time.
-t time Use the specified time instead of the current time. time will be a decimal number of the form:
[[CC]YY]MMDDhhmm [.SS]



Example:

bash-2.03$ ls -l
-rw-rw-r-- 1 root other 18 Aug 10 05:55 test_touch.txt
bash-2.03$ touch test_touch.txt
bash-2.03$ ls -l
-rw-rw-r-- 1 root other 18 Aug 10 10:47 test_touch.txt


^_^

No comments: