Results 1 to 3 of 3
  1. #1
    Join Date
    Jul 2004
    Posts
    18

    Unanswered: 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

  2. #2
    Join Date
    May 2005
    Location
    South Africa
    Posts
    1,365
    Provided Answers: 1
    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

  3. #3
    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!!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •