Linux 命令之刪除命令

在Linux下刪除文件用rm命令,具體用法以下:spa

rm [選項] 文件

選項說明:code

-f    -force      忽略不存在的文件,強制刪除,無任何提示blog

-i    --interactive    進行交互式地刪除遞歸

-r | -R  --recursive     遞歸式地刪除列出的目錄下的全部目錄和文件class

-v      --verbose    詳細顯示進行的步驟file

 

命令實例:touch

一、常規刪除a.txt文件刪除文件

[root]# rm a.txt

 

二、強行刪除file.log文件di

[root]# rm -f file.log

 

 三、刪除dirname目錄下的全部東西文件

[root]# rm -R dir dirname

 

四、刪除以 -f 開頭的文件

[root]# touch ./-f
[root]# ls ./-f
./-f
[root]# rm ./-f

 

或者使用

[root]# touch -- -f 
[root]# ls -- -f 
-f
[root]# rm -- -f   
相關文章
相關標籤/搜索