Linux touch命令詳解


 

touch命令有兩個功能:

一是用於把已存在文件的時間標簽更新為系統當前的時間(默認方式),它們的數據將原封不動地保留下來;

二是用來創建新的空文件。

touch常見命令參數

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
-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
-t STAMP               use [[CC]YY]MMDDhhmm[.ss] instead of current time
-- time =WORD            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
     --version  output version information and exit

 

常用的命令展示

         

touch:創建file1—file10共10個文件

1
touch  file {1..10}

設定文件的時間戳

touch -t 201810121230 hh.sh 【-t用十進制數】

image

更新log.log的時間和log2012.log時間戳相同

1
touch  -r hh hh.sh    【 touch  -r目標文件  源文件】

image


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM