- 論壇徽章:
- 0
|
本帖最后由 shahand 于 2010-12-27 17:30 編輯
=====> 兩者結(jié)果一樣
# 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 同樣的過(guò)濾,結(jié)果就不一樣樣了,后者是期望的結(jié)果。
# 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'是可以替換掉%的,為什么加了通配..就不行了?多出來(lái)的m又是從哪里來(lái)的? |
|