【发布时间】:2011-09-21 17:08:37
【问题描述】:
我正在编写一个 bash 脚本,它需要在一个步骤中获取目标目录(也可能包含文件)中的目录(变量)列表,然后将它们作为参数展开到 python 脚本。
例子:
/stuff/a dir/
/stuff/b other/
/stuff/c/
我需要在 bash 脚本中调用:
script.py "a dir/" "b other/" "c/"
或者,转义空格:
script.py a\ dir/ b\ other/ c/
我需要为目录“stuff”只调用一次脚本。
有没有一种简单的方法来做这种事情?我一直在谷歌搜索,我设法弄清楚的最好的方法是让我知道有多少个目录。
【问题讨论】:
标签: bash command-line-arguments