Re: awk & shell variables

From: erybak (ehudrybak_at_yahoo.com)
Date: 07/31/03


Date: 31 Jul 2003 07:52:39 -0700

sgtembe@hotmail.com (Suhas) wrote in message news:<5c440ee2.0307301326.a5ae28@posting.google.com>...
> Hello Everyone,
>
> Here is what I am trying to do & maybe you guys can throw some light,
> since I am not able to figure it out. I have shell script that
> contains the following:
>
> DB_DIR=/test/data
> DB_NAME=custom
> UID=root
>
> ps -ef | awk '$1 == "'"${UID}"'" && $9 ~ /_mprosrv
> "'"${DB_DIR}"'"'/'"'"${DB_NAME}"'"/'
>
> # I know that the above syntax is incorrect, since I am getting
> errors.
>
> Basically, I am trying to check for a process that has the UID (1st
> column) as "root" & the 9th column contains "_mprosrv
> /test/data/custom".

ps -ef | grep root | egrep "_mprosrv /test/data/custom"

Or you can user a regex inside the " " after egrep.

>
> Thanks in advance.
> Suhas



Relevant Pages

  • Re: [Q] $ARGV, <>, and command-line Perl
    ... find, the command whose output you are processing, can take a regex ... I've left the perl ... simply be performed by egrep (the egrep provides an efficient first-pass ...
    (comp.lang.perl.misc)
  • Re: egrep logical OR
    ... You've got to watch out when your regex begins with a "-" because grep ... and egrep can pick this up as an option. ...
    (comp.unix.shell)
  • Re: how to search/replace text in mutliple files?
    ... I am completely at a loss how to use a regex to search for whitespace. ... > egrep, they match exactly nothing. ... grep regex'es are not perl regex'es: try 'e +w' to match multiple ...
    (Fedora)
  • Re: how to search/replace text in mutliple files?
    ... >them work, although the regex editor in Kate seems to do the job, when I copy ... >egrep, they match exactly nothing. ... >grep 'e w' test.file ... >different lengths of whitespace, etc., but since I can't even search for ONE ...
    (Fedora)