Linux下touch命令的用法

奮起直追CDS發表於2016-01-12

Touch Command Options
a, change the access time only
-c, if the file does not exist, do not create it
-d, update the access and modification times
-m, change the modification time only
-r, use the access and modification times of file
-t, creates a file using a specified time

1.建立一個新的空檔案

# touch sheena

2.建立多個檔案

# touch sheena meena leena

3.只修改access time為現在的時間,-a

# touch -a leena

4.只修改modification time為現在的時間,-m

# touch -m leena

5.如果檔案不存在,避免建立新檔案,-c

# touch -c leena

6.同時精確設定access and modification times,-t

# touch -c -t YYDDHHMM leena

sets the access and modification date and time to a file leena as 17:30 (17:30 p.m.) December 10 of the current year (2012).

# touch -c -t 12101730 leena

7.使用另一個指定文件的access and modifications times設定檔案的時間戳,-r

# touch -r leena meena

8.建立一個新檔案並指定精確的access and modifications times

# touch -t YYMMDDHHMM.SS tecmint
# touch -t 201212101830.55 tecmint

相關文章