bash脚本防止可变迭代我有一个bash脚本中,我限定一定的路径作为这样:在for循环
MY_PATH=/to/my/path
我也有一组my_path的内的目录,并予储存这些目录中一个数组,因此:
DIRECTORIES="/dir1/
/dir2/
/dir3/"
我想要做的是叠代在$ my_path的所有$目录,所以我想这:
for dir in $MY_PATH$DIRECTORIES
do
echo "Processing $dir"
end
然而,这提供了以下不需要输出:
Processing /to/my/path/dir1/ #Correct!
Processing /dir2/ #What I want: Processing /to/my/path/dir2/
Processing /dir3/ #What I want: Processing /to/my/path/dir3/
有什么办法来防止重复超过$ my_path的同时保留迭代超过$目录,以便我能达到预期的输出(见上文)?
哦是的,杜。谢谢! – laker