Shell Make:使用cat将文件与换行合并
我正在为一些用Markdown编写的个人文档编写一个makefile,希望在构建时将所有文件合并在一起,这样我就不必每次添加新文件时都编辑makefile。这是我的代码:Shell Make:使用cat将文件与换行合并,shell,for-loop,makefile,gnu-make,cat,Shell,For Loop,Makefile,Gnu Make,Cat,我正在为一些用Markdown编写的个人文档编写一个makefile,希望在构建时将所有文件合并在一起,这样我就不必每次添加新文件时都编辑makefile。这是我的代码: MERGE: @printf "Merging all files into one...\n" @cp .yaml tmp @for file in *.md;\ do\ cat $$file;\ echo "";\
MERGE:
@printf "Merging all files into one...\n"
@cp .yaml tmp
@for file in *.md;\
do\
cat $$file;\
echo "";\
done > tmp
@mv tmp tmp.md
唉,每当我运行它时,make
就会返回这个并冻结:
Merging all files into one...
cat: 0: No such file or directory
我读到我可能正在调用cat
作为文件?但是我对语法使用了正确的,并将$
转义为$$
那么,我做错了什么?您可以尝试以下循环:
for file in *.md; do
cat "$file"
echo ""
done >> tmp.md
它起作用了。谢谢在哪里可以找到有关传递带引号或不带引号的参数之间的差异的文档?