linux刪除符合條件的檔案

2021-07-04 23:22:59 字數 405 閱讀 1632

找到根目錄下所有的以test開頭的檔案並把查詢結果當做引數傳給rm -rf命令進行刪除:

1、find / -name 「test*」 |xargs rm -rf

2、find / -name 「test*」 -exec rm -rf {} /;

3、rm -rf $(find / -name 「test」)

如果想指定遞迴深度,可以這樣:

1、find / -maxdepth 3 -name 「*.***」 |xargs rm -rf

2、find / -maxdepth 3 -name 「test*」 -exec rm -rf {} /;

3、rm -rf $(find / -maxdepth 3 -name 「test」)

這樣只會查詢三層目錄中符合條件的檔案並刪除掉!

linux查詢符合條件的檔案並刪除

找到根目錄下所有的以test開頭的檔案並把查詢結果當做引數傳給rm rf命令進行刪除 1 find name test xargs rm rf 2 find name test exec rm rf 3 rm rf find name test 如果想指定遞迴深度,可以這樣 1 find maxde...

Linux下刪除所有符合條件的檔案

linux系統下,刪除當前路徑中所有檔名以 test 必須是英文狀態下的雙引號或者單引號 開頭的檔案,當前目錄可以用 表示,也可以用 表示 如當前處於 home downloads 當前資料夾中檔案列表如下 test01.bin test02.txt test03.csv方法1 ute downlo...

linux查詢符合條件的檔案並刪除

找到根目錄下所有的以test開頭的檔案並把查詢結果當做引數傳給rm rf命令進行刪除 1 find name test xargs rm rf 2 find name test exec rm rf 3 rm rf find name test 如果想指定遞迴深度,可以這樣 1 find maxde...