在 Shell 中列出并更改目录和 运行 命令

List and change directory and run command in Shell

我将在将近 6 年之后回到 shell。 我有一个目录结构,比方说,

MainDirectory --> subDirectory1/some.xml
                     --> subDirectory2/some.xml
                     ...
                     ...
                     --> subDirectoryN/some.xml

我想在所有子目录中执行 some.xml 并使用“>”运算符将输出输出到文件中。 什么是合适的脚本?我尝试了几个选项并尝试了一下但无法实现。有人可以帮忙吗?

编辑:

你可以这样做:

cd <path_to_main_directory>
for subdir in */
do
    pushd "$subdir"
    <do_smth> some.xml > output.txt
    popd
done