AIX

AIX

Connect with fellow AIX users and experts to gain knowledge, share insights, and solve problems.


#Power
#Power
 View Only
  • 1.  grep command

    Posted Mon May 28, 2012 09:51 AM

    Originally posted by: rajeshw61


    Hello team,
    i have a problem.

    OS : AIX 5.3

    when i run following command:
    fs=`df -g|grep '^/dev'|grep -vE "cdrom|/audit|/var|/nmon_perfdata|/tmp|/opt|/apps|/acinst|/opt/IBM/ITM|/opt/fusion|/home|/usr/local"| awk '{print $7}'`

    the out put would show follwoing FS :
    /
    /usr
    /application
    /test
    /temp

    etc.,

    what i want is i dont want "/" to be printed in output.for this if i put "/" in above command exclude list it is not giving any out put.

    cany any one help me on this .please let me know if you dont understand my Q.
    #AIX-Forum


  • 2.  Re: grep command

    Posted Tue May 29, 2012 06:49 PM

    Originally posted by: UNIX-OS


    Rajesh,

    Try this:

    
    fs=`df -g|grep 
    '^/dev'|grep -vE 
    "cdrom|/audit|/var|/nmon_perfdata|/tmp|/opt|/apps|/acinst|/opt/IBM/ITM|/opt/fusion|/home|/usr/local|^/$"| awk 
    '{print $7}'`
    

    #AIX-Forum


  • 3.  Re: grep command

    Posted Thu May 31, 2012 08:41 AM

    Originally posted by: rajeshw61


    Hi Friend,
    i tried it but stil it shows the output as :

    *just added ^/$ as an extra thing.....and below is the output
    FileSystem / has exceeded 63% Usage;

    FileSystem /usr has exceeded 87% Usage;

    FileSystem /maxtst has exceeded 86% Usage;

    FileSystem /test has exceeded 87% Usage;

    and i dont want "/" here to be printed as output because by default few of the boxes are above threshhold level
    #AIX-Forum


  • 4.  Re: grep command

    Posted Thu May 31, 2012 09:36 AM

    Originally posted by: Jnewby


    You can utilize the awk command to display lines between two fields (words). For example "/usr" would be my starting point, because it is listed under "/" and "/installs" would be my endpoint, because it is listed last in my output. See below:

    /
    /usr
    /var
    /tmp
    /opt
    /proc
    /admin
    /var/adm/ras/livedump
    /installs

    So using your command I would add an awk statement at the end to eliminate "/". See below:

    df -g|grep '^/dev'|grep -vE "cdrom|/audit|/var|/nmon_perfdata|/tmp|/opt|/apps|/acinst|/opt/IBM/ITM|/opt/fusion|/home|/usr/local"| awk '{print $7}'|awk '/usr/,/installs/'

    My output then displays:

    /usr
    /admin
    /roundy
    /installs

    I hope this helps, thanks.
    #AIX-Forum


  • 5.  Re: grep command

    Posted Thu May 31, 2012 10:04 AM

    Originally posted by: jvk


    Put "/" in your original command under exclude list, but use then 'grep -vEw' instead of 'grep -vE'.
    #AIX-Forum


  • 6.  Re: grep command

    Posted Thu May 31, 2012 11:00 AM

    Originally posted by: rajeshw61


    Perfert!!!

    thanks for both "jky , jnewby".

    tried what jky said and it worked like charm :) dude thanks again.

    and though i did not tried what jnewby told the command makes sense!

    both happy helping!!
    #AIX-Forum


  • 7.  Re: grep command

    Posted Thu May 31, 2012 11:01 AM

    Originally posted by: rajeshw61


    Perfert!!!

    thanks for both "jky , jnewby".

    tried what jky said and it worked like charm :)
    #AIX-Forum