shell - grep/sed/awk 删除某一行之前的所有内容

标签 shell unix sed awk grep

我的命令具有以下原始输出

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

但是,我只想要“当前网络信息:”之后的信息。计算之前的行数不起作用,因为该信息是可变的。另外,英镑符号也是我加上去的。请忽略他们

最佳答案

使用awk:

awk '/Current Network Information/,0' INPUT_FILE

使用sed:

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

关于shell - grep/sed/awk 删除某一行之前的所有内容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8810796/

相关文章:

bash:如何删除最后一个符号

linux - 将 watch 转换为单位文件 systemd

c - 像在原始 shell 中一样处理 Ctrl + C

c - 你将如何有效地实现tail?

linux - 在给定输入的情况下查找一行并在 csv 文件中修改它

linux - 用另一个列表中的下一行替换列表中的字符串

c++ - 在 C++ FAT 文件系统仿真中使用继承委派构造函数

linux - 在 Unix while-do 循环中,比较条件失败

Java改变系统换行符

unix - 在 unix 中操作字符串来创建目录