bash - 将正确的月份开始日和结束日传递给并行

标签 bash shell date parallel-processing gnu-parallel

我想使用 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/

相关文章:

bash - 从文件中获取模式,打印模式而不是匹配的字符串

linux - 如何计算 ps 命令输出 bash 脚本中 rss 和 vsz 之间的关系?

database - 如何在 postgreSQL 中插入日期序列

javascript - 使用 JavaScript 计算到特定日期的剩余天数

shell - 运行进程会弄乱 shell

javascript - Meteor 和 ReactJS - 从 MongoDB 检索日期到字符串?

linux - 查找包含关键字和提取编号的所有行

linux - Bash:在模式之后将一个文件的内容插入到另一个文件中

java - 如何在 Windows 10 环境中从 Java 运行在 Ubuntu 上用 Bash 编写的 shell 脚本?

linux - 找到没有它的二进制文件的路径