Reputation:
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,
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
Upvotes: 0
Views: 65
Reputation: 2691
You can use command paste
and process substitution for this, e.g.:
$ paste <(comm1) <(comm2)
Upvotes: 2
Reputation: 169012
You might want the paste
command.
$ seq 1 3 > a.txt
$ seq 5 10 > b.txt
$ paste a.txt b.txt
1 5
2 6
3 7
8
9
10
Upvotes: 0