【发布时间】:2011-06-04 11:00:07
【问题描述】:
我有一个单行脚本传入Makefile中的foreach函数,如下图:
flag:
$(foreach f, $*.txt, printf "%s\n" 0a "$(grep -o '[0-9]\+' $f | sed 's/.*/read \"&\"/')" "" . w q | ed $f)
可以在here 找到此脚本行的作用。我只是很困惑为什么它不能以这种方式工作,因为如果我将该行放入一个单独的脚本中并像这样从 Makefile 中调用它:
flag:
$(forech f, $*.txt, ./script $f)
效果很好。
我也试过shellfor循环如下:
flag:
for f in $*.txt ; do \
printf "%s\n" 0a "$(grep -o '[0-9]\+' $f | sed 's/.*/read \"&\"/')" "" . w q | ed $f ; \
done
仍然没有运气。我必须触及 Makefiles 的一些微妙点,有人可以启发我吗?谢谢。
【问题讨论】:
标签: shell makefile sed grep ed