Searching value in table through awk

I need to create one script in which I want to search in txt file , this txt file is having 10 columns , I want to check 4th column value if "BOY" & 10th column value =>500 it will print 4th column row value ,1st column row value & 10th column row value & store the same value in one file as following : BOY is running from last 500 Sec.
I have created but it is not working :-

LOGDIR=/file/location/

export MAIL_LIST="xxx@in.xxx.com"
var=$(
cat `find $LOGDIR -type f|sort -r|head -n1` | while read line
do
awk '{
if ($3 -eq "BOY" && $10 >= 500) echo "$3 is running in "$1" from last  "$10" secs"
     }'
done)
echo $var

it is giving the output but different row value which is greater than 500.

I can't tell what half your code is supposed to be doing.

The combination of find, cat, read, and awk you have here is almost certainmly not going to do what you want no matter what you put in any of them.

I think, but can only guess, that this is what you want:

FILE="$(find $LOGDIR -type f|sort -r|head -n1)"

awk '($3 == "BOY") && (($10+0) >= 500) { print $3" is running in "$1" from last "$10" secs"; }' "$FILE"

Without any input data to test on this is the best I can do.

1 Like

Thanks for your reply Corona,
I have tried your code but it is giving output all other values in tables but not which want.I am giving you table example.

Column1    column2  column3 
BOY         200             passed           
GIRL         300             passed
CHILD      100             passed
BOY          500           passed
MAN         50            failed
BOY           50              failed

I want if BOY is greater than 50 print column 3 value of the same row.
$Column1 marks is Coulmn2 ,so passed/failed
output will be like this :-(it should show boy value only)

BOY marks is 200 so passed
BOY marks is 500 so passed
BOY marks is 50 so  failed

but I have tried your query it is showing all other values except boy.

Girl marks is 300 so passed
Child marks is 100 so passed.
Man marks is 50 so failed.

kindly help .

---------- Post updated at 05:19 PM ---------- Previous update was at 03:45 PM ----------

Thanks for your reply Corona,

I have done some mistake, what you have suggested that is working very much, I am very sorry for that.
Just I want to give thanks icon to you but I do not have idea how to give in this forum.
once again thanks for your valuable suggestion & time.:slight_smile:
Kindly suggest.