bash 使用 Linux 在目录中使用通配符查找文件
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/43882412/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Find files using wildcard in directory using Linux
提问by tjcinnamon
So I have a directory that has a number of files. I'm wondering what I need to find files within that directory. My files have a naming convention and then a last name. I'd like to find by the naming convention.
所以我有一个包含许多文件的目录。我想知道在该目录中查找文件需要什么。我的文件有一个命名约定,然后是姓氏。我想通过命名约定找到。
/MyDir/MySubDir/2016_01_randomLastNameABC
/MyDir/MySubDir/2016_01_randomLastNameDEF
/MyDir/MySubDir/2016_01_randomLastNameGHD
/MyDir/MySubDir/2016_01_randomLastNameDGD
find "/MyDir/MySubDir/2016_01_*"
I keep getting an error that says:
我不断收到一条错误消息:
"linux file names usually don't contain slashes"
“linux 文件名通常不包含斜线”
It must not like the fact that I'm trying to search a directory
它一定不喜欢我试图搜索目录的事实
回答by Drew Hoskins
Try
find ./MyDir/MySubdir/ -name "2016_01_*"
尝试
find ./MyDir/MySubdir/ -name "2016_01_*"
回答by Kris Roofe
This will do
这会做
find /MyDir/MySubDir/ -name "2016_01_*"
test,
测试,
~$ find ./market/public/static/ -name *.js
./market/public/static/view3dview.js
./market/public/static/ng-file-upload.min.js
./market/public/static/codemirror-min.js
./market/public/static/model_upload_app.js
回答by kjohri
find /MyDir/MySubDir -name "2016_01_*"