欧美一区二区三区老妇人-欧美做爰猛烈大尺度电-99久久夜色精品国产亚洲a-亚洲福利视频一区二区

linux下rm命令如何使用

這篇“l(fā)inux下rm命令如何使用”文章的知識(shí)點(diǎn)大部分人都不太理解,所以小編給大家總結(jié)了以下內(nèi)容,內(nèi)容詳細(xì),步驟清晰,具有一定的借鑒價(jià)值,希望大家閱讀完這篇文章能有所收獲,下面我們一起來看看這篇“l(fā)inux下rm命令如何使用”文章吧。

成都創(chuàng)新互聯(lián)-專業(yè)網(wǎng)站定制、快速模板網(wǎng)站建設(shè)、高性價(jià)比涇縣網(wǎng)站開發(fā)、企業(yè)建站全套包干低至880元,成熟完善的模板庫,直接使用。一站式?jīng)芸h網(wǎng)站制作公司更省心,省錢,快速模板網(wǎng)站建設(shè)找我們,業(yè)務(wù)覆蓋涇縣地區(qū)。費(fèi)用合理售后完善,十年實(shí)體公司更值得信賴。

rm是常用的命令,該命令的功能為刪除一個(gè)目錄中的一個(gè)或多個(gè)文件或目錄,它也可以將某個(gè)目錄及其下的所有文件及子目錄均刪除。對(duì)于鏈接文件,只是刪除了鏈接,原有文件均保持不變。

rm是一個(gè)危險(xiǎn)的命令,使用的時(shí)候要特別當(dāng)心,尤其對(duì)于新手,否則整個(gè)系統(tǒng)就會(huì)毀在這個(gè)命令(比如在/(根目錄)下執(zhí)行rm * -rf)。所以,我們?cè)趫?zhí)行rm之前最好先確認(rèn)一下在哪個(gè)目錄,到底要?jiǎng)h除什么東西,操作時(shí)保持高度清醒的頭腦。

1.命令格式:
rm [選項(xiàng)] 文件…

2.命令功能:
刪除一個(gè)目錄中的一個(gè)或多個(gè)文件或目錄,如果沒有使用- r選項(xiàng),則rm不會(huì)刪除目錄。如果使用 rm 來刪除文件,通常仍可以將該文件恢復(fù)原狀。

3.命令參數(shù):
    -f, --force    忽略不存在的文件,從不給出提示。
    -i, --interactive 進(jìn)行交互式刪除
    -r, -r, --recursive   指示rm將參數(shù)中列出的全部目錄和子目錄均遞歸地刪除。
    -v, --verbose    詳細(xì)顯示進(jìn)行的步驟
        --help     顯示此幫助信息并退出
        --version  輸出版本信息并退出

4.命令實(shí)例:

實(shí)例一:刪除文件file,系統(tǒng)會(huì)先詢問是否刪除。
命令:
rm 文件名

復(fù)制代碼 代碼如下:

[root@localhost test1]# ll總計(jì) 4-rw-r--r-- 1 root root 56 10-26 14:31 log.logtest1]# rm log.logrm:是否刪除 一般文件 “l(fā)og.log”? ytest1]# ll總計(jì) 0[root@localhost test1]#
說明:輸入rm log.log命令后,系統(tǒng)會(huì)詢問是否刪除,輸入y后就會(huì)刪除文件,不想刪除則數(shù)據(jù)n。
實(shí)例二:強(qiáng)行刪除file,系統(tǒng)不再提示。命令:rm -f log1.log

復(fù)制代碼 代碼如下:

[root@localhost test1]# ll
總計(jì) 4
-rw-r--r-- 1 root root 23 10-26 14:40 log1.log
[root@localhost test1]# rm -f log1.log
[root@localhost test1]# ll
總計(jì) 0[root@localhost test1]#

實(shí)例三:刪除任何.log文件;刪除前逐一詢問確認(rèn)
命令:

rm -i *.log

復(fù)制代碼 代碼如下:

[root@localhost test1]# ll
總計(jì) 8
-rw-r--r-- 1 root root 11 10-26 14:45 log1.log
-rw-r--r-- 1 root root 24 10-26 14:45 log2.log
[root@localhost test1]# rm -i *.log
rm:是否刪除 一般文件 “l(fā)og1.log”? y
rm:是否刪除 一般文件 “l(fā)og2.log”? y
[root@localhost test1]# ll
總計(jì) 0[root@localhost test1]#

實(shí)例四:將 test1子目錄及子目錄中所有檔案刪除
命令:

rm -r test1

復(fù)制代碼 代碼如下:

[root@localhost test]# ll
總計(jì) 24drwxr-xr-x 7 root root 4096 10-25 18:07 scf
drwxr-xr-x 2 root root 4096 10-26 14:51 test1
drwxr-xr-x 3 root root 4096 10-25 17:44 test2
drwxrwxrwx 2 root root 4096 10-25 17:46 test3
drwxr-xr-x 2 root root 4096 10-25 17:56 test4
drwxr-xr-x 3 root root 4096 10-25 17:56 test5
[root@localhost test]# rm -r test1
rm:是否進(jìn)入目錄 “test1”? y
rm:是否刪除 一般文件 “test1/log3.log”? y
rm:是否刪除 目錄 “test1”? y
[root@localhost test]# ll
總計(jì) 20drwxr-xr-x 7 root root 4096 10-25 18:07 scf
drwxr-xr-x 3 root root 4096 10-25 17:44 test2
drwxrwxrwx 2 root root 4096 10-25 17:46 test3
drwxr-xr-x 2 root root 4096 10-25 17:56 test4
drwxr-xr-x 3 root root 4096 10-25 17:56 test5
[root@localhost test]#

實(shí)例五:rm -rf test2命令會(huì)將 test2 子目錄及子目錄中所有檔案刪除,并且不用一一確認(rèn)
命令:

rm -rf  test2

復(fù)制代碼 代碼如下:

[root@localhost test]# rm -rf test2
[root@localhost test]# ll
總計(jì) 16drwxr-xr-x 7 root root 4096 10-25 18:07 scf
drwxrwxrwx 2 root root 4096 10-25 17:46 test3
drwxr-xr-x 2 root root 4096 10-25 17:56 test4
drwxr-xr-x 3 root root 4096 10-25 17:56 test5
[root@localhost test]#

實(shí)例六:刪除以 -f 開頭的文件
命令:

rm -- -f

復(fù)制代碼 代碼如下:

[root@localhost test]# touch -- -f
[root@localhost test]# ls -- -f
-f[root@localhost test]# rm -- -f
rm:是否刪除 一般空文件 “-f”? y
[root@localhost test]# ls -- -f
ls: -f: 沒有那個(gè)文件或目錄
[root@localhost test]#
也可以使用下面的操作步驟:
[root@localhost test]# touch ./-f
[root@localhost test]# ls ./-f
./-f[root@localhost test]# rm ./-f
rm:是否刪除 一般空文件 “./-f”? y
[root@localhost test]#

實(shí)例七:自定義回收站功能
命令:

myrm(){ d=/tmp/$(date +%y%m%d%h%m%s); mkdir -p $d; mv "$@" $d && echo "moved to $d ok"; }

復(fù)制代碼 代碼如下:

[root@localhost test]# myrm(){ d=/tmp/$(date +%y%m%d%h%m%s); mkdir -p $d;  mv "$@" $d && echo "moved to $d ok"; }
[root@localhost test]# alias rm='myrm'
[root@localhost test]# touch 1.log 2.log 3.log
[root@localhost test]# ll
總計(jì) 16
-rw-r--r-- 1 root root    0 10-26 15:08 1.log
-rw-r--r-- 1 root root    0 10-26 15:08 2.log
-rw-r--r-- 1 root root    0 10-26 15:08 3.log
drwxr-xr-x 7 root root 4096 10-25 18:07 scf
drwxrwxrwx 2 root root 4096 10-25 17:46 test3
drwxr-xr-x 2 root root 4096 10-25 17:56 test4
drwxr-xr-x 3 root root 4096 10-25 17:56 test5
[root@localhost test]# rm [123].log
moved to /tmp/20121026150901 ok
[root@localhost test]# ll
總計(jì) 16drwxr-xr-x 7 root root 4096 10-25 18:07 scf
drwxrwxrwx 2 root root 4096 10-25 17:46 test3
drwxr-xr-x 2 root root 4096 10-25 17:56 test4
drwxr-xr-x 3 root root 4096 10-25 17:56 test5
[root@localhost test]# ls /tmp/20121026150901/
1.log  2.log  3.log
[root@localhost test]#

說明:
上面的操作過程模擬了回收站的效果,即刪除文件的時(shí)候只是把文件放到一個(gè)臨時(shí)目錄中,這樣在需要的時(shí)候還可以恢復(fù)過來。

以上就是關(guān)于“l(fā)inux下rm命令如何使用”這篇文章的內(nèi)容,相信大家都有了一定的了解,希望小編分享的內(nèi)容對(duì)大家有幫助,若想了解更多相關(guān)的知識(shí)內(nèi)容,請(qǐng)關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道。

名稱欄目:linux下rm命令如何使用
標(biāo)題路徑:http://www.chinadenli.net/article30/pgepso.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供云服務(wù)器外貿(mào)網(wǎng)站建設(shè)品牌網(wǎng)站設(shè)計(jì)移動(dòng)網(wǎng)站建設(shè)自適應(yīng)網(wǎng)站網(wǎng)站改版

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)

營(yíng)銷型網(wǎng)站建設(shè)