shell命令--touch
0、touch命令的專屬圖床
點此快速打開文章【圖床_shell命令touch】
1、touch命令的功能說明
touch
命令用於創建新的空文件或改變已有文件的時間戳屬性。
2、touch命令的語法格式
SYNOPSIS touch [OPTION]... FILE...
3、touch命令的選項說明
touch
選項不常用,此處省略。
4、touch命令的實踐操作
范例1:創建文件(文件事先不存在的情況)
cd && rm -rf /test -->將之前的實驗環境刪除掉。提示:rm -rf 謹慎使用! mkdir /test cd /test && ls -->&&是並且的意思,可以將兩個命令一起執行,若想多個命令執行,在后面繼續加&& touch file1.txt && ls -->創建單個文件 touch a.txt b.txt && ls -->創建多個文件 touch stu{1..4} && ls -->利用{ }有序序列批量創建文件
范例2:更改文件的時間戳屬性
stat file1.txt touch -a file1.txt --> -a 參數只更改文件的最后訪問時間 !stat -->!作用就是調用最近一次以stat開頭的命令 touch -m file1.txt --> -m 參數只更改文件的最后修改時間 !stat
范例3:指定時間屬性創建/修改文件(不常用,了解即可)
ls -lh file1.txt touch -d 20201010 file1.txt --> -d 參數的用法 !ls ls -lh a.txt touch -r a.txt file1.txt --> -r 參數的用法 ls -lh file1.txt touch -t 201904161914.50 file1.txt --> -t 參數的用法 !ls ls -lh --full-time file1.txt -->查看結果
『MineGi有話說』:快來掃一掃下面鏈接的二維碼,加入我們吧!