新聞中心
這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
Linux下刪除帶有空格的文件
本篇文章重點(diǎn)為大家講解一下Linux下刪除帶有空格的文件具體方法,有需要的小伙伴可以參考一下。

我們是于2013年成立的成都網(wǎng)站建設(shè)公司,提供網(wǎng)站建設(shè),電商網(wǎng)站設(shè)計(jì)開發(fā),外貿(mào)網(wǎng)站制作,響應(yīng)式網(wǎng)頁設(shè)計(jì),小程序定制開發(fā)、等服務(wù)。為客戶創(chuàng)造有價(jià)值的品牌營銷體驗(yàn),讓互聯(lián)網(wǎng)提升企業(yè)的競(jìng)爭(zhēng)力!
大家平時(shí)工作中對(duì)不帶空格的文件接觸較多。這樣一來刪除操作也是比較簡(jiǎn)單的。但是有時(shí)我們會(huì)接觸帶有空格的文件。對(duì)于這種文件我們應(yīng)該如何刪除呢?
首先我們演示一下find命令結(jié)合xargs命令刪除不帶空格的文件
[root@ELK-chaofeng test]# touch 1.txt 2.txt
[root@ELK-chaofeng test]# ls
1.txt 2.txt
[root@ELK-chaofeng test]# find . -type f | xargs
./1.txt ./2.txt
[root@ELK-chaofeng test]# find . -type f | xargs rm -rf
[root@ELK-chaofeng test]# ls
[root@ELK-chaofeng test]#
接下來我們演示刪除帶有空格的文件
[root@ELK-chaofeng test]# touch 1.txt 2.txt '1 2.txt'
[root@ELK-chaofeng test]# ls
1 2.txt 1.txt 2.txt
[root@ELK-chaofeng test]# ll
total 0
-rw-r--r-- 1 root root 0 Feb 14 12:24 1 2.txt
-rw-r--r-- 1 root root 0 Feb 14 12:24 1.txt
-rw-r--r-- 1 root root 0 Feb 14 12:24 2.txt
[root@ELK-chaofeng test]# find . -type f -print0 | xargs -0 rm -rf
[root@ELK-chaofeng test]# ls
上面的參數(shù)-print0,于默認(rèn)的-print相比,輸出的序列不是以空格分隔,而是以null字符分隔。而xargs也有一個(gè)參數(shù)-0,可以接受以null而非空格間隔的輸入流。
文章標(biāo)題:Linux下刪除帶有空格的文件
瀏覽地址:http://www.5511xx.com/article/codojjg.html


咨詢
建站咨詢
