導航:首頁 > 程序命令 > touch命令

touch命令

發布時間:2022-01-14 14:09:51

linux命令的touch命令意思

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

⑵ Linux下touch命令有什麼作用

touch [選項]。。。 文件。。。

-a 或–time=atime或–time=access或–time=use 只更改存取時間。

-c 或–no-create 不建立任何文檔。

-d 使用指定的日期時間,而非現在的時間。

-f 此參數將忽略不予處理,僅負責解決BSD版本touch指令的兼容性問題。

-m 或–time=mtime或–time=modify 只更改變動時間。

-r 把指定文檔或目錄的日期時間,統統設成和參考文檔或目錄的日期時間相同。

-t 使用指定的日期時間,而非現在的時間。

touch命令參數可更改文檔或目錄的日期時間,包括存取時間和更改時間。

實例一:創建不存在的文件

命令:

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 {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命令bin touch 與 touch有什麼區別

/bin/touch 就是 touch
只不過前者加上了全路徑 後者是從環境變數中查詢路徑

也就是說 如果環境變數中 沒有 /bin 這個路徑 那麼touch也就不能運行 使用前者則無這個擔憂

如果是 bin touch的話 我的系統上無法運行 提示
-bash: bin: command not found

我管理的幾台伺服器 分別有redhat debian ubuntuserver 都是這樣

你是什麼發型版 有這么古怪的命令

⑸ Linux中touch的作用。

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

⑹ linux命令中touch命令

-a
更改由
File
變數指定的文件的訪問時間。不會更改修改時間,除非也指定了
-m
標志。
-c
如果文件不存在,則不要進行創建。沒有寫任何有關此條件的診斷消息。
-f
嘗試強制
touch
運行,而不管文件的讀和寫許可權。
-m
更改
File
的修改時間。不會更改訪問時間,除非也指定了
-a
標志。
-r
RefFile
使用由
RefFile
變數指定的文件的相應時間,而不用當前時間。
Time

MMDDhhmm[YY]
的格式指定新時間戳記的日期和時間,其中:
MM
指定一年的哪一月(從
01

12)。
DD
指定一月的哪一天(從
01

31)。
hh
指定一天中的哪一小時(從
00

23)。
mm
指定一小時的哪一分鍾(從
00

59)。
YY
指定年份的後兩位數字。如果
YY
變數沒有被指定,預設值為當前年份。
-t
Time
使用指定時間而不是當前時間。Time
變數以十進制形式
[[CC]YY]MMDDhhmm[.SS]
指定,其中:
CC
指定年份的前兩位數字。
YY
指定年份的後兩位數字。
MM
指定一年的哪一月(從
01

12)。
DD
指定一月的哪一天(從
01

31)。
hh
指定一天中的哪一小時(從
00

23)。
mm
指定一小時的哪一分鍾(從
00

59)。
SS
指定一分鍾的哪一秒(從
00

59)。
注:
1.
touch
命令調用
utime
()
子常式來更改所涉及文件的修改和訪問時間。當沒有真正擁有該文件,即使對文件有寫許可權,使用標志時也可能使
touch
命令失敗。
2.
當使用
touch
命令時,如果接收到錯誤消息,不要指定完整路徑名
/usr/bin/touch。
退出狀態
命令返回以下出口值:
0
命令成功執行。所有請求的更改已完成。
>0
發生一個錯誤。
來源:http://ke..com/view/345328.htm#sub7011236

⑺ Linux下touch命令有什麼作用如何使用

touch命令用於創建空白文件與設置文件的各種時間,格式為:「touch [選項] [文件]」。

這個touch命令可真的是特別好用,它能夠為咱們創建出空白的文本文件,但這實在太簡單不需要去講,例如「touch linuxprobe」這樣就可以創建出一個空白的名為linuxprobe的文本文件,而有難度的操作主要是用於設置文件內容的修改時間(mtime)、文件許可權或屬性的更改時間(ctime)與文件的讀取時間(atime)。

咱們可以在修改一個文件前先查看下文件的修改時間,然後再通過touch命令將修改後的文件時間設置偽裝成自己沒有動過的一樣,很多黑客就會這么做呢:

參數
作用

-a
僅修改「訪問時間」(atime)

-m
僅修改「更改時間」(mtime)

-d
同時修改atime與mtime

[root@localhost ~]# ls -l anaconda-ks.cfg
-rw-------. 1 root root 1213 May 4 15:44 anaconda-ks.cfg
[root@localhost ~]# echo "Visit the LinuxProbe.com to learn linux skills" >> anaconda-ks.cfg
[root@localhost ~]# ls -l anaconda-ks.cfg
-rw-------. 1 root root 1260 Aug 2 01:26 anaconda-ks.cfg
[root@localhost ~]# touch -d "2016-05-04 15:44" anaconda-ks.cfg
[root@localhost ~]# ls -l anaconda-ks.cfg
-rw-------. 1 root root 1260 May 4 15:44 anaconda-ks.cfg

推薦你看下http://www.linuxprobe.com/chapter-02.html這個章節鞏固下基礎知識

⑻ linux touch命令

7.txt在當前路徑下,即/7.txt

⑼ 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

⑽ touch命令在windows下對應什麼命令

1.在windows10 powershell上可以使用ni命令實現touch的效果,例如我在桌面上新建一個Hello.txt文件,可以執行:
ni Hello.txt
2.如果你使用的是win7或者cmd可以使用cd命令實現對應的效果,例如同樣在桌面上創建一個Hello.txt文件,可以執行:
cd . >Hello.txt
有人建議使用下面這個命令
echo >Hello.txt
但是這個命令在生成新文件的同時會在新文件中寫入一行空行,相比之下第一個命令更合適一些。

閱讀全文

與touch命令相關的資料

熱點內容
解壓電波歌曲大全 瀏覽:336
為啥文件夾移到桌面成word了 瀏覽:858
命令符的安全模式是哪個鍵 瀏覽:758
編程中學 瀏覽:956
單片機求助 瀏覽:992
ug加工側面排銑毛坯怎麼編程 瀏覽:271
程序員有關的介紹 瀏覽:736
支付寶使用的什麼伺服器 瀏覽:210
安卓看本地書用什麼軟體好 瀏覽:921
經傳軟體滾動凈利潤指標源碼 瀏覽:522
螢石雲視頻已加密怎麼解除 瀏覽:574
一命令四要求五建議 瀏覽:30
qq文件夾遷移不了 瀏覽:19
液體粘滯系數測定不確定度演算法 瀏覽:332
輕棧源碼 瀏覽:426
把圖片壓縮到500k 瀏覽:35
命令你自己 瀏覽:369
51單片機c語言pdf下載 瀏覽:177
androidactivity堆棧 瀏覽:821
mac執行命令 瀏覽:897