[英]Find files in multiple directories
I am using RHEL. 我正在使用RHEL。 In my current folder there are sub folders.
在我当前的文件夹中有子文件夹。 I need to find where a file is in the subfolders.
我需要找到子文件夹中文件的位置。 The files may be in one or more.
文件可以是一个或多个。
I am using this but it iterates infinitely: 我正在使用它,但它无限迭代:
for f in ./{Failed,Loaded,ToLoad}; do find -name 'file'; done
How to get this right? 如何做到这一点?
Try doing this : 试着这样做:
find {Failed,Loaded,ToLoad} -name 'file'
if {Failed,Loaded,ToLoad}
are really some dirs. 如果
{Failed,Loaded,ToLoad}
真的是一些dirs。
The syntax of your for-loop is incorrect. 你的for循环语法不正确。
It should be: 它应该是:
for f in Failed Loaded ToLoad
do
find "$f" -name 'file'
done
But you don't need a loop. 但是你不需要循环。 It can simply be done like this:
它可以简单地这样做:
find Failed Loaded ToLoad -name 'file'
find
can take multiple arguments for source directory. find
可以为源目录提供多个参数。 So, you could use: 所以,你可以使用:
find Failed Loaded ToLoad -name 'file' ...
You don't need a loop. 你不需要循环。 This can be handy if you want
find
to look at a subset of your subdirectories. 如果您希望
find
子目录的子集,这可能很方便。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.