Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/shell/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Shell Make:使用cat将文件与换行合并_Shell_For Loop_Makefile_Gnu Make_Cat - Fatal编程技术网

Shell Make:使用cat将文件与换行合并

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 "";\

我正在为一些用Markdown编写的个人文档编写一个makefile,希望在构建时将所有文件合并在一起,这样我就不必每次添加新文件时都编辑makefile。这是我的代码:

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     

它起作用了。谢谢在哪里可以找到有关传递带引号或不带引号的参数之间的差异的文档?