Chinaunix首页 | 论坛 | 博客
  • 博客访问: 524757
  • 博文数量: 122
  • 博客积分: 2024
  • 博客等级: 上尉
  • 技术积分: 1484
  • 用 户 组: 普通用户
  • 注册时间: 2010-01-08 21:17
文章分类

全部博文(122)

文章存档

2012年(2)

2011年(25)

2010年(95)

分类: LINUX

2010-05-31 17:08:35

I have a file:
  7 P-states (frequencies)
  8   2.81 Ghz   100.0%
  9   1400 Mhz     0.0%
 10   1050 Mhz     0.0%
 11    700 Mhz     0.0%
 12    350 Mhz     0.0%
I could grep out the P-states line,but what i want is the next line,to extract  the 100,and How?
It's sed,and thanks to kexin.the code is:

  3 val=`sed -n -e  '/P-states/{
  4 n
  5 p
  6 }' busy.output | awk '{print $3}'`
  7
  8 echo $val
  9
 10 val=${val%.*}
 11
 12 echo $val

and "n" means i put the next line to pattern space,and "p" prints it,great!
阅读(1221) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~