linux – 如何将多个参数传递给unix命令?

linux – 如何将多个参数传递给unix命令?,第1张

概述我找不到类似的东西,因此发布了这个问题. 假设我有一组提供输出的命令 第一组产生输出 cat xyx.txt | awk '{.........}' | sed 's/.../' | cut -d.... 第二组产生输出 cat abc.txt | awk '{.........}' | cut -d ... | sed 's/...../' 我希望将这些输出作为“join”命令的2个参数.我知道 我找不到类似的东西,因此发布了这个问题.

假设我有一组提供输出的命令

第一组产生输出

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命令?所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/yw/1026605.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-23
下一篇 2022-05-23

发表评论

登录后才能评论

评论列表(0条)

保存