假设我有一组提供输出的命令
第一组产生输出
cat xyx.txt | awk '{.........}' | sed 's/.../' | cut -d....
第二组产生输出
cat abc.txt | awk '{.........}' | cut -d ... | sed 's/...../'
我希望将这些输出作为“join”命令的2个参数.我知道我可以将这两个文件重定向,然后使用join命令将文件作为参数.
基本上,整个事情可以在一行中完成……就像
[first set of commands] > join -1 1 -2 1 < [second set of commands]解决方法 如果您使用bash(许多linux发行版中的默认shell),则表达式为:
join <([first set of commands]) <([second set of commands])
已验证.
所以
join <(cat xyx.txt | awk '{.........}' | sed 's/.../' | cut -d....) <(cat abc.txt | awk '{.........}' | cut -d ... | sed 's/...../')
应该成功.
基本的例子
$cat a1 hello2 bye3 Ciao$cat b1 hello 1232 bye 4563 adios 789$cut -d' ' -f1,2 b | awk '{print ,2,}'1 2 hello2 2 bye3 2 adios$join <(cut -d' ' -f1,}') a1 2 hello hello2 2 bye bye3 2 adios Ciao总结
以上是内存溢出为你收集整理的linux – 如何将多个参数传递给unix命令?全部内容,希望文章能够帮你解决linux – 如何将多个参数传递给unix命令?所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)