需要一个删除除的* .pdf的所有文件的shell脚本 [英] Need a shell script that deletes all files except *.pdf

查看:103
本文介绍了需要一个删除除的* .pdf的所有文件的shell脚本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

任何人都可以写一个删除除该文件夹中的所有文件与shell脚本 PDF 延期?

Can anyone write a shell script that deletes all the files in the folder except those with pdf extension?

推荐答案

这将包括所有子目录:

find . -type f ! -iname '*.pdf' -delete

这会在当前目录中唯一的行动:

This will act only in the current directory:

find . -maxdepth 1 -type f ! -iname '*.pdf' -delete

这篇关于需要一个删除除的* .pdf的所有文件的shell脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆