且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

查找扩展名为5个或更多字符的文件

更新时间:2022-11-28 16:41:45

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.

相关阅读

技术问答最新文章