If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > Unix Shell Scripts > grep command help~

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 04-03-06, 01:13
steadybompipi steadybompipi is offline
Registered User
 
Join Date: Jul 2004
Posts: 18
grep command help~

Hi all,

I have a log file name abc.log which contain my computer cpu usage:


0.0 rpc portmap
0.0 root xinetd -stayalive -pidfile /var/run/xinetd.pid
0.0 root /usr/sbin/sshd
0.0 root /usr/sbin/automount --timeout=60 /misc file /etc/auto.misc
0.0 root /usr/sbin/atd
0.0 root syslogd -m 0
0.0 root sshd: root@pts/0
0.0 root sort -rn
0.0 root sendmail: accepting connections
0.0 root /sbin/mingetty tty6
0.0 root /sbin/mingetty tty5
0.0 root /sbin/mingetty tty4
0.0 root /sbin/mingetty tty3
0.0 root /sbin/mingetty tty2
0.0 root [rpciod]
0.0 root ps -e -o pcpu -o ruser,args
0.0 root [mdrecoveryd]
0.0 root mdadm --monitor --scan -f
0.0 root [lockd]
0.0 root [kupdated]
0.0 root [kswapd]
0.0 root [ksoftirqd/0]
0.0 root [kscand]
0.0 root klogd -x
0.0 root [kjournald]
0.0 root [kjournald]
0.0 root [kjournald]
0.0 root [kjournald]
0.0 root [kjournald]
0.0 root [kjournald]
0.0 root [kjournald]
0.0 root [khubd]
0.0 root [keventd]
0.0 root [kapmd]
0.0 root init
0.0 root gpm -t imps2 -m /dev/mouse

so now, i would like to grep for the range of number 80.00 to 100.00. hence my command is as below:
cat abc.log | grep -i "[8-9][0-9].[0-9][0-9]"
cat abc.log | grep -i 100.00
but strangely, the return result is not very accurate.

can kindly advice?

thanks
Reply With Quote
  #2 (permalink)  
Old 04-03-06, 02:34
pdreyer pdreyer is offline
Registered User
 
Join Date: May 2005
Location: South Africa
Posts: 1,268
Your data contain only one decimal point, and just in case you have a number between 80 and 100 in the command args I suggest you execute
egrep "^100.0|^[8-9][0-9].[0-9]" abc.log
Reply With Quote
  #3 (permalink)  
Old 04-03-06, 10:04
steadybompipi steadybompipi is offline
Registered User
 
Join Date: Jul 2004
Posts: 18
sorry for the error in my typing.
the command should be cat abc.log | grep -i "[8-9][0-9].[0-9], and the result is not accurate previously.

but now, i follow your guide by putting ^, and it's work. thanks!!
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On