综合技术

Grep / sed / awk all before a certain line

微信扫一扫,分享到朋友圈

Grep / sed / awk all before a certain line
0

My command has the following raw output

Wi-Fi:

      Software Versions:
          CoreWLAN: 2.1.1 (211.3)
          CoreWLANKit: 1.0.1 (101.1)
          Menu Extra: 7.0.1 (701.2)
          configd plug-in: 7.1.1 (711.1)
          System Profiler: 7.0 (700.3)
          IO80211 Family: 4.1.1 (411.1)
          WiFi Diagnostics: 1.0.1 (101.1)
          AirPort Utility: 5.5.3 (553.20)
      Interfaces:
        en1:
          Card Type: AirPort Extreme  (0x14E4, 0xD6)
          Firmware Version: Broadcom BCM43xx 1.0 (5.100.98.75.18)
          MAC Address: xx:xx:xx:xx:xx:xx
          Locale: FCC
          Country Code: US
          Supported PHY Modes: 802.11 a/b/g/n
          Supported Channels: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140, 149, 153, 157, 161, 165
          Wake On Wireless: Supported
          AirDrop: Supported
          Status: Connected
         **Current Network Information:**
            PEETS:
              PHY Mode: 802.11g
              BSSID: 00:17:c5:0c:85:50
              Channel: 6
              Country Code: US
              Network Type: Infrastructure
              Security: None
              Signal / Noise: -52 dBm / -89 dBm
              Transmit Rate: 54
          Other Local Wi-Fi Networks:
            hpsetup:
              PHY Mode: 802.11b
              BSSID: ba:78:b7:86:78:69
              Channel: 6
              Network Type: Computer-to-Computer
              Security: None
              Signal / Noise: -90 dBm / -92 dBm
            yogurtland:
              PHY Mode: 802.11g
              BSSID: 0c:d5:02:7b:ce:5b
              Channel: 11
              Network Type: Infrastructure
              Security: WEP
              Signal / Noise: -72 dBm / -92 dBm

However, I only want the information past "Current Network Information:". Counting the lines before does not work as that information is variable. Also, the pound signs were put in by me. Please ignore them

Using awk
:

awk '/Current Network Information/,0' INPUT_FILE

Using sed
:

sed -n '/Current Network Information/,$p' INPUT_FILE

阅读原文...


微信扫一扫,分享到朋友圈

Grep / sed / awk all before a certain line
0

Hello, buddy!

33 亿美元收购换来“失望”,沃尔玛重组闪购网站 Jet.com

上一篇

《最好的我们》破 2 亿 这是“最好的青春片”吗?

下一篇

评论已经被关闭。

插入图片

热门分类

Grep / sed / awk all before a certain line

长按储存图像,分享给朋友