當前位置:首頁 » 操作系統 » touchlinux

touchlinux

發布時間: 2022-09-02 23:01:38

linux的touch命令怎麼用

linux的touch命令不常用,一般在使用make的時候可能會用到,用來修改文件時間戳,或者新建一個不存在的文件。
1|0命令格式:
touch [選項]... 文件...

2|0命令參數:
-a 或--time=atime或--time=access或--time=use 只更改存取時間。-c 或--no-create 不建立任何文檔。-d 使用指定的日期時間,而非現在的時間。-f 此參數將忽略不予處理,僅負責解決BSD版本touch指令的兼容性問題。-m 或--time=mtime或--time=modify 只更改變動時間。-r 把指定文檔或目錄的日期時間,統統設成和參考文檔或目錄的日期時間相同。-t 使用指定的日期時間,而非現在的時間。《Linux就該這么學》 一起學習linux
3|0命令功能:
touch命令參數可更改文檔或目錄的日期時間,包括存取時間和更改時間。
4|0使用範例:
實例一: 創建不存在的文件
命令:
touch log2012.log log2013.log
輸出:[root@localhost test]# touch log2012.log log2013.log
[root@localhost test]# ll
-rw-r--r-- 1 root root 0 10-28 16:01 log2012.log
-rw-r--r-- 1 root root 0 10-28 16:01 log2013.log
如果log2014.log不存在,則不創建文件
[root@localhost test]# touch -c log2014.log
[root@localhost test]# ll
-rw-r--r-- 1 root root 0 10-28 16:01 log2012.log
-rw-r--r-- 1 root root 0 10-28 16:01 log2013.log

實例二: 更新log.log的時間和log2012.log時間戳相同
命令:touch -r log.log log2012.log
輸出:[root@localhost test]# ll
-rw-r--r-- 1 root root 0 10-28 16:01 log2012.log
-rw-r--r-- 1 root root 0 10-28 16:01 log2013.log
-rw-r--r-- 1 root root 0 10-28 14:48 log.log
[root@localhost test]# touch -r log.log log2012.log
[root@localhost test]# ll-rw-r--r-- 1 root root 0 10-28 14:48 log2012.log
-rw-r--r-- 1 root root 0 10-28 16:01 log2013.log
-rw-r--r-- 1 root root 0 10-28 14:48 log.log

實例三: 設定文件的時間戳
命令:touch -t 201211142234.50 log.log
輸出:[root@localhost test]# ll
-rw-r--r-- 1 root root 0 10-28 14:48 log2012.log
-rw-r--r-- 1 root root 0 10-28 16:01 log2013.log
-rw-r--r-- 1 root root 0 10-28 14:48 log.log
[root@localhost test]# touch -t 201211142234.50 log.log
[root@localhost test]# ll
-rw-r--r-- 1 root root 0 10-28 14:48 log2012.log
-rw-r--r-- 1 root root 0 10-28 16:01 log2013.log
-rw-r--r-- 1 root root 0 2012-11-14 log.log

Ⅱ linux命令的touch命令意思

linux中的touch命令一般用來修改文件的時間,或者新建一個不存在的文件.
-a                    只更改訪問時間

Ⅲ linux常用命令的「cat」和「touch」有什麼區別

名稱:cat
使用許可權:所有使用者
使用方式:cat [-AbeEnstTuv] [--help] [--version] fileName
說明:把檔案串連接後傳到基本輸出(螢幕或加 > fileName 到另一個檔案)
參數:
-n 或 --number 由 1 開始對所有輸出的行數編號
-b 或 --number-nonblank 和 -n 相似,只不過對於空白行不編號
-s 或 --squeeze-blank 當遇到有連續兩行以上的空白行,就代換為一行的空白行
-v 或 --show-nonprinting

範例:
cat -n textfile1 > textfile2 把 textfile1 的檔案內容加上行號後輸入 textfile2 這個檔案里
cat -b textfile1 textfile2 >> textfile3 把 textfile1 和 textfile2 的檔案內容加上行號(空白行不加)之後將內容附加到 textfile3
名稱:touch
使用許可權:所有使用者

使用方式:
touch [-acfm]
[-r reference-file] [--file=reference-file]
[-t MMDDhhmm[[CC]YY][.ss]]
[-d time] [--date=time] [--time={atime,access,use,mtime,modify}]
[--no-create] [--help] [--version]
file1 [file2 ...]

說明:
touch 指令改變檔案的時間記錄。 ls -l 可以顯示檔案的時間記錄。

參數:
a 改變檔案的讀取時間記錄。
m 改變檔案的修改時間記錄。
c 假如目的檔案不存在,不會建立新的檔案。與 --no-create 的效果一樣。
f 不使用,是為了與其他 unix 系統的相容性而保留。
r 使用參考檔的時間記錄,與 --file 的效果一樣。
d 設定時間與日期,可以使用各種不同的格式。
t 設定檔案的時間記錄,格式與 date 指令相同。
--no-create 不會建立新檔案。
--help 列出指令格式。
--version 列出版本訊息。

範例:

最簡單的使用方式,將檔案的時候記錄改為現在的時間。若檔案不存在,系統會建立一個新的檔案。

touch file
touch file1 file2

將 file 的時間記錄改為 5 月 6 日 18 點 3 分,公元兩千年。時間的格式可以參考 date 指令,至少需輸入 MMDDHHmm ,就是月日時與分。

touch -c -t 05061803 file
touch -c -t 050618032000 file

將 file 的時間記錄改變成與 referencefile 一樣。

touch -r referencefile file

將 file 的時間記錄改成 5 月 6 日 18 點 3 分,公元兩千年。時間可以使用 am, pm 或是 24 小時的格式,日期可以使用其他格式如 6 May 2000 。

touch -d "6:03pm" file
touch -d "05/06/2000" file
touch -d "6:03pm 05/06/2000" file

Ⅳ linux 如何用TOUCH命令 一次建立多個文件例如想建1.txt 2.txt……9.txt

必須用shell吧?,你這要求很變態啊,囧了。
我去試試再說吧
額,另外,touch命令不支持正則表達式
額,如下,寫一個shell腳本
#!/bin/bash
for filename in $( seq 1 10 )
do
touch ${filename}.txt
done
然後運行之,即可

Ⅳ 請教linux下的touch命令建立文件

touch命令用來修改文件的訪問時間、修改時間。如果沒有指定時間,則將文件時間屬性改為當前時間。當指定文件不存在,則touch命令變為創建該文件。
語法:
touch [-acm] [-d STRING-time] [-r reference-file] [-t [[CC]YY]MMDDhhmm[.ss]]

選項介紹:
-a: 只修改訪問時間;
-c: 如果指定文件不存在,則不創建文件;
-d STRING-time: 用字元串格式的時間來指定時間屬性的修改值;
-m: 只修改指定文件的修改時間;
-r refernce-file: 將指定文件的時間屬性改為與reference-file時間屬性相同的值;
-t [[CC]YY]MMDDhhmm[.ss]: 用[[CC]YY]MMDDhhmm[.ss]這種時間格式來指定時間屬性的修改值;
使用範例:
實例一:創建不存在的文件
命令:
touch log2012.log log2013.log
輸出:
[root@localhost test]# touch log2012.log log2013.log
[root@localhost test]# ll
-rw-r--r-- 1 root root 0 10-28 16:01 log2012.log
-rw-r--r-- 1 root root 0 10-28 16:01 log2013.log

如果log2014.log不存在,則不創建文件
[root@localhost test]# touch -c log2014.log
[root@localhost test]# ll
-rw-r--r-- 1 root root 0 10-28 16:01 log2012.log
-rw-r--r-- 1 root root 0 10-28 16:01 log2013.log

實例二:更新log.log的時間和log2012.log時間戳相同
命令:
touch -r log.log log2012.log
輸出:
[root@localhost test]# ll
-rw-r--r-- 1 root root 0 10-28 16:01 log2012.log
-rw-r--r-- 1 root root 0 10-28 16:01 log2013.log
-rw-r--r-- 1 root root 0 10-28 14:48 log.log
[root@localhost test]# touch -r log.log log2012.log
[root@localhost test]# ll
-rw-r--r-- 1 root root 0 10-28 14:48 log2012.log
-rw-r--r-- 1 root root 0 10-28 16:01 log2013.log
-rw-r--r-- 1 root root 0 10-28 14:48 log.log

實例三:設定文件的時間戳
命令:
touch -t 201211142234.50 log.log
輸出:
[root@localhost test]# ll
-rw-r--r-- 1 root root 0 10-28 14:48 log2012.log
-rw-r--r-- 1 root root 0 10-28 16:01 log2013.log
-rw-r--r-- 1 root root 0 10-28 14:48 log.log
[root@localhost test]# touch -t 201211142234.50 log.log
[root@localhost test]# ll
-rw-r--r-- 1 root root 0 10-28 14:48 log2012.log
-rw-r--r-- 1 root root 0 10-28 16:01 log2013.log
-rw-r--r-- 1 root root 0 2012-11-14 log.log
說明:
-t time 使用指定的時間值 time 作為指定文件相應時間戳記的新值.此處的 time規定為如下形式的十進制數:
[[CC]YY]MMDDhhmm[.SS]
這里,CC為年數中的前兩位,即」世紀數」;YY為年數的後兩位,即某世紀中的年數.如果不給出CC的值,則touch 將把年數CCYY限定在1969--2068之內.MM為月數,DD為天將把年數CCYY限定在1969--2068之內.MM為月數,DD為天數,hh 為小時數(幾點),mm為分鍾數,SS為秒數.此處秒的設定范圍是0--61,這樣可以處理閏秒.這些數字組成的時間是環境變數TZ指定的時區中的一個時 間.由於系統的限制,早於1970年1月1日的時間是錯誤的。

Ⅵ linux為什麼要用touch創建文件

vi需要鍵盤輸入,也就是和人互動,這就無法實現自動化腳本運行
次要原因這個操作耗時較長,往快了說估計也要1秒鍾
如果我有個任務,要創建100萬個文件,那要到猴年馬月了

Ⅶ linux命令中touch {1..100}中的..是什麼意思

touch {1..100} 中, touch 是更新文件時間戳命令,無文件則創建。

(假如你的shell環境為bash)

{1..100}bash花括弧展開表達式

1 表示起始的數字

.. 表示連續的意思

100表示終止數字的意思,也包括這個數字

步進為1, 左右閉合

命令執行時,bash會自動展開touch {1..100} 就變成了 touch 1 2 3 4 5 6 7 此處省略 100

截圖是bash的源碼中處理花括弧(curly braces)的掃描代碼。文件為: braces.c

並且這個花括弧表達式是在3.0以上bash中使用。

Ⅷ Linux裡面touch -a命令作用是什麼

touch -a是改變文件讀取時間的

Ⅸ Linux中touch的作用。

1、使用touch命令創建一個單個文件test,執行touchtest,如圖所示:

熱點內容
python實用代碼 發布:2025-05-13 22:19:41 瀏覽:841
dede資料庫的配置文件 發布:2025-05-13 22:19:08 瀏覽:966
給字元加密 發布:2025-05-13 22:12:32 瀏覽:972
資料庫系統實現答案 發布:2025-05-13 22:11:57 瀏覽:140
哪個軟體可以共存安卓 發布:2025-05-13 22:10:15 瀏覽:552
上傳宦妃天下野泉肉肉 發布:2025-05-13 22:10:10 瀏覽:408
洗眼睛解壓 發布:2025-05-13 21:58:28 瀏覽:272
c存儲指針 發布:2025-05-13 21:49:04 瀏覽:921
結繩編程軟體 發布:2025-05-13 21:49:03 瀏覽:850
解壓體育館 發布:2025-05-13 21:27:48 瀏覽:263