[英]displaying 2 outputs as a 2 separate columns | bash
I have two outputs from 2 commands: 我有两个命令的两个输出:
comm1=`ip a | grep ens | grep -v lo | cut -d' ' -f2`
output example: 输出示例:
>eth1
and command two 并命令两个
comm2=`ip a | grep inet| grep -v inet6 | grep -v 127 | cut -d' ' -f6`
output example: 输出示例:
>123.156.789
234.167.290
148.193.198
138.25.49
142.137.154
125.175.166
246.173.7
154.167.67
Desired output: 所需的输出:
echo "$comm1 $comm2"
> eth1 123.156.789
234.167.290
148.193.198
138.25.49
142.137.154
125.175.166
246.173.7
154.167.67
If that would be single line outputs, then column -t works just fine, 如果那是单行输出,那么列-t可以正常工作,
echo "$comm1 $comm2" | column -t
but in this case, when one of the columns is multi line, it is not working.. Looking for an efficient solution 但是在这种情况下,当其中一列是多行时,它将无法正常工作。
edited 已编辑
您可以为此使用命令paste
和进程替换 ,例如:
$ paste <(comm1) <(comm2)
You might want the paste
command. 您可能需要paste
命令。
$ seq 1 3 > a.txt
$ seq 5 10 > b.txt
$ paste a.txt b.txt
1 5
2 6
3 7
8
9
10
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.