当前位置: 技术问答>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)}'
本站(WWW.)旨在分享和传播互联网科技相关的资讯和技术,将尽最大努力为读者提供更好的信息聚合和浏览方式。
本站(WWW.)站内文章除注明原创外,均为转载、整理或搜集自网络。欢迎任何形式的转载,转载请注明出处。
本站(WWW.)站内文章除注明原创外,均为转载、整理或搜集自网络。欢迎任何形式的转载,转载请注明出处。