Below is my script :
where i am using your given code..and somehow its not giving desired o/p.
can you please tell me what is wrong in this...
#SCRIPT TO CHECK WHO HAS ACCESSED THE LOG/FILE IN PAST 'N' MINUTES, AND MAIL ACCORDINGLY.
MYPATH="/clocal/mqbrkrs/user/mqsiadm/sanjay/" MAIL_RECIPIENTS="vg517@dcx.com"
Subject=":: File(s) accessed/touched in last few minutes ::"
>tempmail.txt
>tempfind.txt
>filterfile.txt
>tempgrep.txt
#*******************************************************************************************************************************************************
## List all the files which one accessed since last 1 min #####
#********************************************************************************************************************************************************
I tried using :
fpm=`awk '$2=="966906" {print $3}' tempfind.txt` | sed -n "/$fpm/p" tempfind.txt
but still its not working. Whenever I do only awk '$2=="966906" {print $3}' tempfind.txt it works and gives the value of $3, but when we assign $3 to fpm variable, its not going ahead.
Even i have tried..
fpm=`awk '$2=="966906" {print $3}' tempfind.txt` | echo "$fpm"
It does not show anything.
Where is the matter ?? Please suggust me, this is the last thing in my script and am waiting to complete it.
AFAIK the problem lies in using single quotes in the second awk command. You are running a nested awk, so using single quotes again will confuse the initial outer awk script, (I ran into the same problem before).
So I'd suggest try to avoid the single quotes and use the other methods shown here to assign the variables.
Means I want the 999 only corrosponding to the search, but as awk works on records and $3 represent whole third column, it used to give me
888
999
555
all the three values in filefilter., BUT i want only 999 (respective to the matched record and its 3rd cell value.)
Sure, but I was refering to the issues using single quotes in a nested awk. Back to your awk command, I see no issues using it as is. From the command line the output is correct: