1、创建测试数据
[root@centos7 test2]# touch a.txt b.txt c.txt; mkdir test01 test02 test03
[root@centos7 test2]# ls
a.txt b.txt c.txt test01 test02 test03
2、删除所有文件
[root@centos7 test2]# ls --file-type
a.txt b.txt c.txt test01/ test02/ test03/
[root@centos7 test2]# ls --file-type | grep -v "/$"
a.txt
b.txt
c.txt
[root@centos7 test2]# ls --file-type | grep -v "/$" | xargs rm -f
[root@centos7 test2]# ls
test01 test02 test03
3、删除所有的目录文件
[root@centos7 test2]# touch a.txt b.txt c.txt
[root@centos7 test2]# ls
a.txt b.txt c.txt test01 test02 test03
[root@centos7 test2]# ls --file-type
a.txt b.txt c.txt test01/ test02/ test03/
[root@centos7 test2]# ls --file-type | grep "/$"
test01/
test02/
test03/
[root@centos7 test2]# ls --file-type | grep "/$" | xargs rm -rf
[root@centos7 test2]# ls
a.txt b.txt c.txt
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。