查找扩展名为5个或更多字符的文件 [英] Find files with extension with 5 characters or more

查看:316
本文介绍了查找扩展名为5个或更多字符的文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有很多来自失败的rsync命令的残留文件。他们都有一个5(随机)字符的文件扩展名。有一个命令,可以找到扩展名为4个字符和更多递归的所有文件?



一个rsync残留文件名的例子:foo.jpg.hzmkjt7



我已经找到了一种防止rsync的方法,但我现在要做的就是清理那些剩下的东西...

globstar 像这样:

  shopt -s globstar#启用shell选项
echo ** / *。 #来测试哪些文件匹配
rm ** / *。 #如果您满意的话

该模式匹配当前目录中的任何文件或任何结尾的子目录一个后跟5个字符。



code>?,你可以通过更改glob使其更类似于 ** / *。[[:alnum:]] [[:alnum:] ] [[:alnum:]] [[:alnum:]] [[:alnum:]] 以匹配5个字母数字字符。


I have a lot of residue files from a failed rsync-command. They all have a file extension of 5 (random)characters. Is there a command that can find all files with an extension of 4 characters and more recursively?

Example of a rsync residue filename: foo.jpg.hzmkjt7

I've already found out a way to prevent this with rsync, but all I need to do now is clean those leftovers...

解决方案

Using bash, one option would be to use globstar like this:

shopt -s globstar # enable the shell option
echo **/*.?????   # to test which files are matched
rm **/*.?????     # if you're happy

The pattern matches any files in the current directory or any subdirectories that end in a . followed by 5 characters.

Rather than matching any character with a ?, you could go more specific by changing the glob to something like **/*.[[:alnum:]][[:alnum:]][[:alnum:]][[:alnum:]][[:alnum:]] to match 5 alphanumeric characters.

这篇关于查找扩展名为5个或更多字符的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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