0
我需要编写一个脚本(比如说A),它将在多个 目录中运行脚本(说B)。脚本B在一组子目录中运行一个脚本(比如C)。虽然我 写和成功地执行脚本B和C,结合他们和写作 脚本A对我来说似乎有点太难。在脚本中使用脚本运行脚本
B的一个例子是
MainDir="/home/kkk/mmm/dir"
create_stack="${MainDir}/run/create_stack_and_find_seam.rb"
# cd into the working main directory where all the subdirs are present
for fil_no in [email protected]
do
cd ${MainDir}/${fil_no}
pwd
# the working script
echo ${fil_no}
${create_stack} ${fil_no}
done
# Go back to the original starting directory
cd $OLDPWD
上述(脚本B)的脚本中的Ruby脚本 “create_stack_and_find_seam.rb” 在一组目录fil_no征。 现在我有几个不同的子目录在不同层次上列出“fil_no”在 。 因此,我现在需要在所有目录中执行脚本B,在Turn中将在所有不同的子目录中运行 “create_stack_and_find_seam.rb”(即脚本C)。
我会'脚本B的'MainDir'参数,然后'脚本A'调用选择不同的'脚本B ”。例如,脚本A会运行'ScriptB.sh/home/kkk/mmm/dir',然后运行'ScriptB.sh/home/kkk/mmm/differntdir'等。这可能有助于http://doitwithlinux.blogspot.co.uk/2012/05/slightly-more-advanced-guide-to-shell.html – SpaceCowboy
请您提供一些清晰的问题?是红宝石脚本递归搜索目录并从$ MainDir进行处理?现在如果你单独运行它,它会这样做吗?目录结构的一些想法也可能有所帮助。 – suspectus
Hi @suspectus - – user2209882