使用$ for column的Makefile Awk会出现语法错误,而它在控制台上运行正常

时间:2013-08-27 13:38:24

标签: awk makefile syntax-error

我在控制台上完全使用下面这行,但是当我在makefile中使用它时,我得到以下错误。我在最后一小时尝试了不同的东西,没有什么可以帮助我。我也必须使用' @'在makefile中的命令之前,这只是正常的。非常欢迎任何帮助。

控制台上的命令

cpio -itv < rootfs.cpio | awk '!/^d/{$8="";print}' | sort -k8 > rootfs.layout.trim

错误

awk: !/^d/{="";print}
awk:       ^ syntax error

在makefile中

log-rootfs:
# copy the layout dump with all the modification needed to sync with stb output
# get the file list from cpio file => remove the lines with directory name => sort the output and store the same in layout file
cpio -itv < $(ROOTFS_CPIO_FILE) | awk '!/^d/{$8="";print}' | sort -k8 > $(ROOTFS_LAYOUT)
@echo $(ROOTFS_LAYOUT) is created

1 个答案:

答案 0 :(得分:2)

make正在寻找名为$8的变量/宏。通常,$需要在makefile中进行转义,如果要将文本$传递给shell,则应在makefile中使用$$。换句话说,尝试:

rule:
  ... awk '!/^d/{$$8="";print}' ...