get a name according to the 2nd field

Hi,

I have a file with this format:

name number
-------------- -----------
AAA 11700
BBB 6000
CCC 6000

I want to catch any of these names if number > 200

How to do that?

at a further step, if none are > 200, see if the sum of any is > 200 and catch these names.

PS: as a first step, I just need the first step.

thanks

> cat file156
AAA 11700
BBB 6000
CCC 6000
DDD 100
EEE 199
FFF 200
GGG 201

> awk '$2>200 {print $1}' file156
AAA
BBB
CCC
GGG

melanie,
you've been quite a 'busy beaver' posting to this Forums lately with members providing solutions.
There are plenty of similar posts - try searching and taking a stab at it yourself.
I'm sure if/when you need specific help, someone will be will to help.

Hint: 'man awk'

Good luck.

Try this, assuming your data is in a file called myfile:

awk '{if ($2 > 200) {print $1}}' myfile

thanks.

so it is

awk '$2>200' /tmp/output | awk '{print $1}' | grep AAA | head -1
AAA

So that I get the first name that has a number > 200 (all these names have AAA in common, so I want to get rid of the first and last name)

do you suggest a more compact way to do this?

thanks again