作者LIAR (玻璃做的大叔)
看板RegExp
标题[问题] 如何从特定行後开始处理?
时间Tue Apr 5 10:19:20 2016
我用linux 的bash,有时输出的stdout前面会有一些警告或其他不相关的资讯
譬如gdisk你有没有GPT的输出就会不一样,但是我只要抓後面的分割表资讯
***************************************************************
Found invalid GPT and valid MBR; converting MBR to GPT format
in memory.
***************************************************************
Warning! Secondary partition table overlaps the last partition by
33 blocks!
You will need to delete this partition or resize it in another utility.
Disk /dev/sda: 2930275055 sectors, 1.4 TiB
Logical sector size: 512 bytes
Disk identifier (GUID): B39B51E9-4599-4F74-93A2-294DF2860F14
Partition table holds up to 128 entries
First usable sector is 34, last usable sector is 2930275021
Partitions will be aligned on 8-sector boundaries
Total free space is 35699733 sectors (17.0 GiB)
Number Start (sector) End (sector) Size Code Name
1 63 1646699 804.0 MiB 8300 Linux filesystem
2 1690000 5450000 1.8 GiB 8300 Linux filesystem
3 5559999 11979999 3.1 GiB 8300 Linux filesystem
5 11999999 17187199 2.5 GiB 8300 Linux filesystem
6 17187299 19045799 907.5 MiB 8300 Linux filesystem
7 20000000 25329999 2.5 GiB 8300 Linux filesystem
也就是蓝色部分。唯一的共通点我看就是在 红色那行的下面。
我有想过抓数字开头,但是绿色那行会被抓到。
虽然可能还可以加上空白解决这个案例的要求,
不过我想请问的是有没有通用的,真的根据特定文字行当作一个tag当起点,
再从那边开始撷取?
--
"Don't hate the player. Hate the game."
当看到哪个名人赚了大钱,领到高额补助或利息,不要去指责他,
而是要指责那个制度、创造那个制度的人,以及默许那个制度的人。
不然你认为一个人不领18%或是一个人不炒房价,就会改变整体环境吗?
还不如改变【修改制度的人】,才能从根源改变一切。
--
※ 发信站: 批踢踢实业坊(ptt.cc), 来自: 180.176.36.217
※ 文章网址: https://webptt.com/cn.aspx?n=bbs/RegExp/M.1459822763.A.048.html
1F:推 weiclin: dosomething | sed -n '/^Number/,$p' 04/05 11:05
2F:→ LIAR: 我以为sed是以行为单位,可以用贪婪直接抓到全部结束啊? 04/05 11:21
3F:→ LIAR: 这种sed用法真的没看过,受教了 04/05 11:26
4F:推 LPH66: 这个用法是 /^Number/,$ 指定符合 /^Number/ 那行到结束 04/05 17:33
5F:→ LPH66: 在这个范围内执行 p 指令印出该行 04/05 17:33
6F:→ LPH66: 原本会印的每一行由 -n 抑制了 04/05 17:33