[英]ipcalc output and grep. Want to return only the binary output
我有一個使用ipcalc的命令,該命令給了我這個輸出。 有沒有辦法使用sed或awk僅顯示二進制值?
homer@deusexmachina ~/Documents $ ipcalc 192.168.1.2 | grep Address
Address: 192.168.1.2 11000000.10101000.00000001. 00000010
這樣輸出看起來像這樣:
11000000.10101000.00000001。 00000010
提前致謝。
您可以使用awk
打印第三列和第四列
ipcalc 192.168.1.2 | awk '/Address/ {print $3,$4}'
您可以使用sed
,但是awk
會更容易
ipcalc 192.168.1.2 | sed -n 's/Address: \+[^ ]\+ \+//p'
因為您標記了linux
,所以很可能您的sed
支持-r
ipcalc 192.168.1.2 | sed -r -n 's/Address: +[^ ]+ +//p'
怎么樣?
$ ipcalc 192.168.1.2 | grep Address | cut -d " " -f14-
或awk:
$ ipcalc 192.168.1.2 | awk '{ if ($1 == "Address:") { print $3 $4 }}'
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.