2014-12-31 38 views
0

在UNIX机器上,我想将文本文件中glance命令的输出转换为文本文件,以便稍后'grep'所需的信息。在文本文件中查看命令输出

是否可以做到这一点?

Glance C.05.00.000    03:28:23 hht013a4  ia64                   Current Avg High 
------------------------------------------------------------------------------------------------------------------------------------------------------ 
CPU Util S                              | 4% 4% 4% 
Disk Util F F                              | 3% 3% 3% 
Mem Util S      SU                     UF F  | 96% 96% 96% 
Swap Util U                    UR      R     | 86% 86% 86% 
------------------------------------------------------------------------------------------------------------------------------------------------------ 
                    PROCESS LIST               Users= 2 
         User  CPU % Thrd Disk  Memory  Block 
Process Name  PID  Name (400% max) Cnt IOrate  RSS/VSS  On 
-------------------------------------------------------------------------------- 
glance    11441 jg212p  9.5  1 12.8  1.5mb 7.0mb SLEEP 
nfs_async_io   44 root   0.0  2 0.0 187.8mb 211.3mb SYSTM 
java    4663 acssim2  0.0 65 0.0 1.72gb 2.95gb SLEEP 
java    17992 websphe2  0.0 101 0.0 840.2mb 1.73gb SLEEP 
java    16811 websphe1  0.0 98 0.0 791.6mb 1.71gb SLEEP 
java    29155 websphe4  0.0 87 0.0 565.6mb 1.71gb SLEEP 
java    22322 isadm   0.0 31 0.0 123.8mb 442.9mb SLEEP 
java    29003 websphe3  0.0 87 0.0 572.4mb 1.71gb SLEEP 
java    28530 websphe1  0.0 88 0.0 583.4mb 1.71gb SLEEP 
java    5836 websphe1  0.0 149 0.0 2.40gb 2.84gb SLEEP 
java    12411 acssim5  0.0 66 0.0 1.90gb 2.96gb SLEEP 
java    23341 acssim3  0.0 71 0.0 2.35gb 3.09gb SLEEP 
java    23524 websphe5  0.0 97 0.0 797.0mb 1.72gb SLEEP 
java    21153 websphe4  0.0 97 0.0 802.7mb 1.72gb SLEEP 
java    19243 acssim6  0.0 59 0.0 1.71gb 2.93gb SLEEP 
+3

使用'glance ...> filename' –

回答

0

你可以用它除了会发送输出的额外拷贝到文件在屏幕上显示它-f选项。例如:

glance -f myfile.out 
0

获得结果并避免在终端输出的唯一方法是使用adviser_only模式。

glance人:

-aos filename Use this option as an alternative to -adviser_only 
       -syntax filename option. 


    -iterations count 
       This option allows you to limit the number of intervals 
       that Glance will run. This can be used in conjunction 
       with the -adviser_only option which enables glance to 
       run in the background with no terminal screen displays. 
       Glance will execute for the number of iterations 
       specified and then terminate. The minimum iteration 
       value is 2 which will be used if the count is specified 
       as 2 or less. 

一个真实的例子:

glance -aos gl.syn -iterations 2 > gl.out 

有:

$ cat gl.syn 
print "CPU total:",gbl_cpu_total_util_cum|3|0 

结果:

$ cat gl.out 
CPU total:7.5% 
CPU total:7.6%