假设有如下目录文件且文件很多:
dir/dir1/*.txt、*.PS
dir/dir2/*.txt、*.PS
dir/dir3/*.txt、*.PS
dir/*.txt、*.log、*.xml
怎么使用find指令只删除dir下面的*.txt文件?
[root@webserver dir]# tree
.
|-- dir1
| |-- good.txt
| |-- nihao.txt
| |-- sdfsdf.ps
| `-- test.txt
|-- dir2
| |-- sdflhlghggsdf.ps
| |-- wer.txt
| `-- wwerwerwer.txt
`-- dir3
|-- 123.txt
|-- 451278.xml
|-- 456.txt
`-- 789.log
3 directories, 11 files
[root@webserver dir]# find ./ -name *.txt
./dir1/good.txt
./dir1/nihao.txt
./dir1/test.txt
./dir2/wer.txt
./dir2/wwerwerwer.txt
./dir3/456.txt
./dir3/123.txt
[root@webserver dir]# find ./ -name *.txt | xargs rm -rf
[root@webserver dir]# tree
.
|-- dir1
| `-- sdfsdf.ps
|-- dir2
| `-- sdflhlghggsdf.ps
`-- dir3
|-- 451278.xml
`-- 789.log
整理论坛帖子
阅读(702) | 评论(0) | 转发(0) |