查找所有文件名以指定字符串开头的文件? [英] Find all files with a filename beginning with a specified string?
本文介绍了查找所有文件名以指定字符串开头的文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的目录中大约有100000个文件,我想对所有以指定字符串开头的文件执行某些功能,该字符串可能匹配成千上万个文件.
I have a directory with roughly 100000 files in it, and I want to perform some function on all files beginning with a specified string, which may match tens of thousands of files.
我尝试过
ls mystring*
,但这会返回bash错误参数过多".我的下一个计划是使用
but this returns with the bash error 'Too many arguments'. My next plan was to use
find ./mystring* -type f
,但这有相同的问题.
but this has the same issue.
代码需要看起来像
for FILE in `find ./mystring* -type f`
do
#Some function on the file
done
推荐答案
将find
与通配符一起使用:
find . -name 'mystring*'
这篇关于查找所有文件名以指定字符串开头的文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文