使用shell脚本,我想查找以特定前缀开头的目录(不是递归)中的所有目录,然后遍历它们。伪代码示例:
array directories = find('/etc/build', 'project-build-*');
foreach (string directory in directories)
{
// directory == 'project-build-example-x64'
do_something_with('/etc/build/' + directory + '/Makefile');
}
答案 0 :(得分:5)
for dir in "/etc/build/project-build-"*/
do
do_something_with "$dir"Makefile
done
答案 1 :(得分:1)
以下是find
和xargs
find /etc/build/project-build-*/ -maxdepth 1 -name Makefile | xargs do_something