1. 程式人生 > >Linux 命令之刪除命令

Linux 命令之刪除命令

在Linux下刪除檔案用rm命令,具體用法如下:

rm [選項] 檔案

選項說明:

-f    -force      忽略不存在的檔案,強制刪除,無任何提示

-i    --interactive    進行互動式地刪除

-r | -R  --recursive     遞迴式地刪除列出的目錄下的所有目錄和檔案

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

命令例項:

1、常規刪除a.txt檔案

[root]# rm a.txt

2、強行刪除file.log檔案

[root]# rm -f file.log

 3、刪除dirname目錄下的所有東西

[root]# rm -R dir dirname

4、刪除以 -f 開頭的檔案

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

或者使用

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

轉:https://www.cnblogs.com/scplee/p/5478992.html