使用if语句进行awk调用时出现语法错误,无需工作

时间:2016-08-11 20:57:04

标签: awk

我在makefile中有一个简单的awk行打印出文件的每一行。

getHeroes() {
  this.heroService.getHeroes()
                  .filter(h => h.id > 10)
                  .subscribe(
                     heroes => this.heroes = heroes,
                     error =>  this.errorMessage = <any>error);
}

运行make时工作正常。但是foo.h中有一些我不希望转移到bar.c.所以我修改了awk。

awk '{print $0}' ../foo/foo.h >> bar.c

但是我收到了语法错误。

awk '{if ($0 != "#include \"foobar.h\"") {print $0}}' ../foo/foo.h >> bar.c

我猜这是我的一个简单错误,但我无法弄明白。

1 个答案:

答案 0 :(得分:3)

在makefile中,您需要将美元符号加倍。

    awk '{if ($$0 != "#include \"foobar.h\"") {print $$0}}' ../foo/foo.h >> bar.c
相关问题