- 论坛徽章:
- 0
|
本帖最后由 shahand 于 2010-12-27 17:30 编辑
=====> 两者结果一样
# top -n 1 |grep Cpu
Cpu(s): 3.0%us, 0.3%sy, 0.0%ni, 96.5%id, 0.2%wa, 0.0%hi, 0.0%si, 0.0%st
# top -n 1 -b |grep Cpu
Cpu(s): 3.0%us, 0.3%sy, 0.0%ni, 96.5%id, 0.2%wa, 0.0%hi, 0.0%si, 0.0%st
=====> 加了sed 同样的过滤,结果就不一样样了,后者是期望的结果。
# top -n 1 |grep Cpu |sed -e 's#%..##g'
Cpu(s): 3.0mus, 0.3msy, 0.0mni, 96.5mid, 0.2mwa, 0.0mhi, 0.0msi, 0.0mst
# top -n 1 -b |grep Cpu |sed -e 's#%..##g'
Cpu(s): 3.0, 0.3, 0.0, 96.5, 0.2, 0.0, 0.0, 0.0
=====> 基本原因:
-b : Batch mode operation
Starts top in 'Batch mode', which could be useful for sending output from top to other programs or
to a file. In this mode, top will not accept input and runs until the iterations limit you've set
with the '-n' command-line option or until killed.
=====> 更多原因?
# top -n 1 |grep Cpu |sed -e 's#%##g' 或者sed -e 's/%//g'是可以替换掉%的,为什么加了通配..就不行了?多出来的m又是从哪里来的? |
|