grep 启动后台进程



我有一个包含多个路径的输入文件,其中一个指向初始解决方案。对应的行如下:

initial_solution_file = ../../INIT/foo

我想做的是有一个别名来显示此路径,以便我键入"init",shell 将返回" 初始解决方案是:../../INIT/foo">

我尝试的是:

grep initial_solution_file input_file | awk '{print $3}' | echo "the initial solution is:" `xargs echo`

它提供了所需的输出,但我另外得到的是这样的内容: [6] 48201 48202

这是什么以及如何防止它发生?

提前致谢

 echo "the initial solution is: $(awk '/initial_solution_file/{print $3}' input_file)"
the initial solution is: ../../INIT/foo

不需要管道,可以使用$(....)构造进行命令替换。此外,grepawk可以单独通过awk来完成。

最新更新