私は2つの質問を1つにまとめようとしています。 IP情報の出力を取得しようとしていますが、これはホストファイルに対して別のクエリと比較され、最終的にデータベースにダンプされます。私のコマンドは、それらがどのように配備されているので、単純なライナーでなければなりません。私はこれら2つで必要なものを手に入れることができますが、それらを組み合わせる方法はあります。 ip showは複数行の出力を出力し、どのように行を組み合わせるか分かりません。Linuxのライナーがeth名、ip、mac、サブネットを返す
ip -o addr show | awk '/inet/ {print $9, $4}' | grep -v '127.0.0.1'
ip -o addr show | awk '/link/ {print $2, $13}' | grep -v lo
トップは、ほとんどの情報を提供し、bottomはmacを取得します。これは両方を与えますが、それは私が必要とする値をawkする方法が不明なので、複数行です。どんな良い考えやトリックですか?まだLinux/bash上で新しいです。
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 16436 qdisc noqueue state UNKNOWN \ link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
1: lo inet 127.0.0.1/8 scope host lo
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP qlen 1000\ link/ether xx:xx:xx:xx:xx:xx brd ff:ff:ff:ff:ff:ff
2: eth0 inet x.x.x.x/24 brd x.x.x.x scope global eth0
3: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP qlen 1000\ link/ether xx:xx:xx:xx:xx:xx brd ff:ff:ff:ff:ff:ff
3: eth1 inet x.x.x.x/24 brd x.x.x.x scope global eth1
4: eth2: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP qlen 1000\ link/ether xx:xx:xx:xx:xx:xx brd ff:ff:ff:ff:ff:ff
4: eth2 inet x.x.x.x/27 brd x.x.x.x scope global eth2
5: eth3: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN qlen 1000\ link/ether xx:xx:xx:xx:xx:xx brd ff:ff:ff:ff:ff:ff
6: eth4: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP qlen 1000\ link/ether xx:xx:xx:xx:xx:xx brd ff:ff:ff:ff:ff:ff
6: eth4 inet x.x.x.x/24 brd x.x.x.x scope global eth4
7: eth5: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP qlen 1000\ link/ether xx:xx:xx:xx:xx:xx brd ff:ff:ff:ff:ff:ff
7: eth5 inet x.x.x.x/24 brd x.x.x.x scope global eth5
8: eth6: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP qlen 1000\ link/ether xx:xx:xx:xx:xx:xx brd ff:ff:ff:ff:ff:ff
8: eth6 inet x.x.x.x/28 brd x.x.x.x scope global eth6
9: eth7: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN qlen 1000\ link/ether xx:xx:xx:xx:xx:xx brd ff:ff:ff:ff:ff:ff
[編集]あなたの質問を入力するので、我々は推測していないことを考えると、予想される出力を表示します。 –
Stack Overflowは、プログラミングおよび開発に関する質問のサイトです。この質問は、プログラミングや開発に関するものではないので、話題にはならないようです。ヘルプセンターの[ここではどのトピックを参照できますか](http://stackoverflow.com/help/on-topic)を参照してください。おそらく、[スーパーユーザ](http://superuser.com/)や[Unix&Linux Stack Exchange](http://unix.stackexchange.com/)の方が良いかもしれません。また、[Dev Opsについての質問はどこに投稿しますか?](http://meta.stackexchange.com/q/134306) – jww