1. 程式人生 > 其它 >linux常用命令二

linux常用命令二

mkdir (make directory) 建立資料夾

解釋:Create the DIRECTORY(ies), if they do not already exist。(建立不存在的資料夾,如果存在則建立失敗)
mkdir 資料夾名稱 建立單個資料夾
mkdir {資料夾1,資料夾2,資料夾3,....} 一次性建立多個資料夾
mkdir 資料夾{1..100} 建立檔案1,資料夾2,資料夾3...資料夾100  (一次性建立100個資料夾)
mkdir -p 資料夾1/資料夾2/資料夾3  遞迴式建立資料夾,父類與與子類資料夾一起建立(如果資料夾都存在則建立失敗)

mkdir test01

mkdir {test02,test03}



nkdir aa{1..5}

mkdir -p bb/bb1/bb2

rm (remove) 刪除(移除)檔案或者多個檔案(重要命令)

解釋:Remove (unlink) the FILE(s) 刪除檔案
rm -f  強制刪除,忽略不存在的檔案,不提示確認。
rm -i  刪除前需要確認(刪除提示)。
rm -I  在刪除3個以上檔案或者遞迴刪除前要求確認。
rm -d  刪除空目錄,有提示。
rm -r  遞迴刪除目錄及內容,有提示。
rm -v  詳細顯示進行的步驟。

rm aa.txt

rm -i bb.txt

rm -I cc.txt ee.txt dd.txt ff.txt gg.txt



rm -d test01

rm -r test01

rm -v test01

rm -f aa.txt

touch 建立檔案或者多個檔案

解釋:Update the access and modification times of each FILE to the current time.A FILE argument that does not exist is created empty, unless -c or -h
is supplied(將每個檔案的訪問和修改時間更新為當前時間,不存在的檔案引數將被建立為空,除非使用-c或-h選項)
touch作用:
1. 建立普通檔案(空檔案)
2. 修改檔案的時間
touch {1..10}  建立多個檔案  
touch {a..z}  建立多個檔案
touch -t 202204220810 file    使用[[CC]YY]MMDDhhmm[.ss]代替當前時間(使用年月日時分秒格式修改檔案的時間)
touch file   如果file 檔案存在,則只是修改了檔案的時間。

touch aa.txt(檔案不存在)

touch aa.txt(檔案存在),檔案存在的情況下,只是修改檔案的時間

touch aa{1..5}.txt(建立多個檔案)

touch -t 202203231011 aa1.txt(修改檔案時間)