繁体   English   中英

我如何在makefile shell命令中使用管道?

[英]how do I use pipes in a makefile shell command?

我在Makefile中有以下代码片段,除非我在下面删除对sed和grep的引用,否则它始终会失败。

TAB=$(shell printf "\t")
all: abstract.tsv
      $(shell cut -d "${TAB}" -f 3 abstract.tsv | sed "s/^\s*//" | \
        sed "s/\s*$//" | grep -v "^\s*$" | sort -f -S 300M | \
        uniq > referenced_images.sorted.tsv)

这是我得到的错误:

/bin/bash: -c: line 0: unexpected EOF while looking for matching `"'
/bin/bash: -c: line 1: syntax error: unexpected end of file

有什么事吗

sed是一个错误。 当你写:

sed "s/\s*$//"

make将变量$/扩展为空字符串,因此sed缺少分隔符。 尝试:

sed "s/\s*$$//"

grep使用$"会导致相同的问题。请改用grep -v "^\\s*$$"

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM