Register
It is currently Fri Dec 19, 2014 6:27 am

strange character after ">>"


All times are UTC - 6 hours


Post new topic Reply to topic  [ 3 posts ] 
Author Message
 PostPosted: Fri Mar 19, 2010 8:01 am   

Joined: Fri Mar 19, 2010 7:58 am
Posts: 1
I use below bash script
Code:
#!/usr/bin/bash

top -n 1 -s | head -n 4 >> tmp.tmp
line=` cat tmp.tmp|wc -l `
echo $line
while [ $line -gt 0 ]
do
a=`cat tmp.tmp | head -n $line | tail -n 1 `
echo $a
echo $a >> tmp1.tmp
line=`expr $line - 1`
done

========
I vi the tmp.tmp and tmp1.tmp file
It is strange character .
Why ??? how can I fix it ...

Code:
^[[H^[[2J^[[m^[(Btop - 17:49:08 up 19 min,  2 users,  load average: 0.09, 0.16, 0.28^[[m^[(B^[[39;49m^[[K
Tasks:^[[m^[(B^[[39;49m^[[m^[(B  74 ^[[m^[(B^[[39;49mtotal,^[[m^[(B^[[39;49m^[[m^[(B   1 ^[[m^[(B^[[39;49mrunning,^[[m^[(B^[[39;49m^[[m^[(B  73 ^[[m^[(B^[[39;49msleeping,^[[m^[(B^[[39;49m^[[m^[(B   0 ^[[m^[(B^[[39;49mstopped,^[[m^[(B^[[39;49m^[[m^[(B   0 ^[[m^[(B^[[39;49mzombie^[[m^[(B^[[39;49m^[[K
Cpu(s):^[[m^[(B^[[39;49m^[[m^[(B  0.6% ^[[m^[(B^[[39;49mus,^[[m^[(B^[[39;49m^[[m^[(B 10.8% ^[[m^[(B^[[39;49msy,^[[m^[(B^[[39;49m^[[m^[(B  0.0% ^[[m^[(B^[[39;49mni,^[[m^[(B^[[39;49m^[[m^[(B 81.1% ^[[m^[(B^[[39;49mid,^[[m^[(B^[[39;49m^[[m^[(B  7.3% ^[[m^[(B^[[39;49mwa,^[[m^[(B^[[39;49m^[[m^[(B  0.2% ^[[m^[(B^[[39;49mhi,^[[m^[(B^[[39;49m^[[m^[(B  0.0% ^[[m^[(B^[[39;49msi^[[m^[(B^[[39;49m^[[K
Mem: ^[[m^[(B^[[39;49m^[[m^[(B  2567708k ^[[m^[(B^[[39;49mtotal,^[[m^[(B^[[39;49m^[[m^[(B   391228k ^[[m^[(B^[[39;49mused,^[[m^[(B^[[39;49m^[[m^[(B  2176480k ^[[m^[(B^[[39;49mfree,^[[m^[(B^[[39;49m^[[m^[(B    44964k ^[[m^[(B^[[39;49mbuffers^[[m^[(B^[[39;49m^[[K
~
~
~
~
~
~
~
~
"tmp.tmp" 4L, 912C


Top
 Profile  
 PostPosted: Fri Mar 19, 2010 9:31 am   

Joined: Mon Mar 02, 2009 3:03 am
Posts: 579
all this seems pretty useless, you'd better get the values you need directly from /proc/meminfo


Top
 Profile  
 PostPosted: Mon Mar 22, 2010 5:48 am   
Moderator
User avatar

Joined: Thu Oct 11, 2007 7:12 am
Posts: 229
Location: London - UK
top is designed for use as an interactive process, it therefore outputs lots of formatting characters. Do not use top for this, there are many other tools for gathering system information.

I suggest using sar
http://www.netadmintools.com/art576.html
i haven't read the above site to see if it's actually useful but there are lots of sites with help about using sar.


Top
 Profile  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
cron


BashScripts | Promote Your Page Too
Powered by phpBB © 2011 phpBB Group
© 2003 - 2011 USA LINUX USERS GROUP