linux command


Linux Command – touch ใช้ในการเปลี่ยนแปลง file timestamps



1. สร้าง file เปล่า

touch <file>

$ touch test
$ ls -ltr test
-rw-rw-r-- 1 root root 0 May 10 10:16 test


2. เปลี่ยนแปลงเวลา modification time ของ file

touch -t <time[YYYYMMDDHHMISS]> <file>

$ touch -t 201705100900 test
$ ls -ltr test
-rw-rw-r-- 1 root root 0 May 10 09:00 test



 touch [OPTION]... FILE...



เป็นคำสั่งที่ใช้ในการเปลี่ยนแปลง file timestamps รวมถึงสามารถสร้าง file เปล่าได้



 A FILE argument that does not exist is created empty, unless -c or -h is supplied.

 A FILE argument string of - is handled specially and causes touch to change the times of the file associated with standard output.

 Mandatory arguments to long options are mandatory for short options too.

 -a change only the access time

 -c, --no-create
 do not create any files

 -d, --date=STRING
 parse STRING and use it instead of current time

 -f (ignored)

 -h, --no-dereference
 affect each symbolic link instead of any referenced file (useful only on systems that can change the timestamps of a symlink)

 -m change only the modification time

 -r, --reference=FILE
 use this file's times instead of current time

 use [[CC]YY]MMDDhhmm[.ss] instead of current time

 change the specified time: WORD is access, atime, or use: equivalent to -a WORD is modify or mtime: equivalent to -m

 --help display this help and exit

 output version information and exit

 Note that the -d and -t options accept different time-date formats.





คำสั่ง Unix – Linux Command

Linux, Unix


Author: Suphakit Annoppornchai


Leave a Reply