当前位置: 技术问答>linux和unix
求教一个shell脚本,字符串提取问题。
来源: 互联网 发布时间:2016-11-03
本文导语: Disk /dev/hda: 8589 MB, 8589934592 bytes 255 heads, 63 sectors/track, 1044 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Device Boot Start End Blocks Id System /dev/hda1 * 1 ...
Disk /dev/hda: 8589 MB, 8589934592 bytes
255 heads, 63 sectors/track, 1044 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/hda1 * 1 993 7976241 83 Linux
/dev/hda2 994 1044 409657+ 5 Extended
/dev/hda5 994 1044 409626 82 Linux swap / Solaris
Disk /dev/hdc: 21.4 GB, 21474836480 bytes
15 heads, 63 sectors/track, 44384 cylinders
Units = cylinders of 945 * 512 = 483840 bytes
Device Boot Start End Blocks Id System
/dev/hdc1 1 44384 20971408+ 83 Linux
要把cylinders前面的数字提取出来要怎么写。试了grep之类的,不行。。
|
cat test.txt | sed -n "/Disk /dev/hdc/,/cylinders/p" | grep "cylinders$" | awk '{print $(NF-1)}'