我想使用 GNU 并行来运行一堆这样的命令:
python MyScript.py 20131101 20131130
python MyScript.py 20131201 20131231
python MyScript.py 20140101 20140131
(etc)
所以这个问题( How to use bash to get the last day of each month for the current year without using if else or switch or while loop? )展示了如何使用 bash 获取每个月的最后一天。
但我不清楚如何将多个参数传递给并行,我认为将重复运行 shell 脚本来生成开始/结束日期。
有没有办法从命令行轻松完成此操作,或者我应该首先生成所有日期并将它们放入文件中以供并行读取,还是有更好的方法?
最佳答案
类似这样的事情:
myfunc() {
MyScript.py $1 $(date -d "$1 + 1 month - 1 day" "+%Y%m%d")
}
export -f myfunc
parallel myfunc ::: 2013{01..12}01
关于bash - 将正确的月份开始日和结束日传递给并行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22189784/