内容简介:代码日志版权声明:翻译自:http://stackoverflow.com/questions/2791069/how-to-use-parallel-execution-in-a-shell-script
我有一个C shell脚本,这样做:
#!/bin/csh gcc example.c -o ex gcc combine.c -o combine ex file1 r1 <-- 1 ex file2 r2 <-- 2 ex file3 r3 <-- 3 #... many more like the above combine r1 r2 r3 final \rm r1 r2 r3
有没有办法让线1,2和3并行运行而不是另一个?
将其转换为具有适当依赖关系的Makefile.那么你可以使用make -j来让Make一切都可以并行运行.
请注意,Makefile中的所有缩进都必须是TAB. TAB显示在哪里运行命令.
另请注意,这个Makefile现在使用GNU Make扩展(通配符和subst函数).
它可能看起来像这样:
export PATH := .:${PATH}
FILES=$(wildcard file*)
RFILES=$(subst file,r,${FILES})
final: combine ${RFILES}
combine ${RFILES} final
rm ${RFILES}
ex: example.c
combine: combine.c
r%: file% ex
ex $< $@
代码日志版权声明:
翻译自:http://stackoverflow.com/questions/2791069/how-to-use-parallel-execution-in-a-shell-script
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持 码农网
本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们。
Introduction to Linear Optimization
Dimitris Bertsimas、John N. Tsitsiklis / Athena Scientific / 1997-02-01 / USD 89.00
"The true merit of this book, however, lies in its pedagogical qualities which are so impressive..." "Throughout the book, the authors make serious efforts to give geometric and intuitive explanations......一起来看看 《Introduction to Linear Optimization》 这本书的介绍吧!
JS 压缩/解压工具
在线压缩/解压 JS 代码
XML 在线格式化
在线 XML 格式化压缩工具