Need help on grep command

Hi Team,

I have the below file .
ID            Name      Hours Worked      Hourly Pay
1425      Juan      18                        14.25
4321      George      22                        21.11
6781      Anne      44                        16.77
1451      Ben            36                        21.77
2277      Tuan      16                        18.77

I need help on the below comamnds on grep, Iam new to grep

I need to display the hourly pay of anne (only the last field )
using grep command.

Secondly , One line comamnd to find the id and hours worked for employees who earn more than $20 per hour.
sam_2012Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

SujithData ArchitectCommented:
bld@dev$ more test.txt
ID            Name      Hours Worked      Hourly Pay
1425      Juan      18                        14.25
4321      George      22                        21.11
6781      Anne      44                        16.77
1451      Ben            36                        21.77
2277      Tuan      16                        18.77

I need to display the hourly pay of anne (only the last field )

bld@dev$ grep -i anne test.txt | awk '{print $4}'
16.77

find the id and hours worked for employees who earn more than $20 per hour -

bld@dev$ grep -v "ID" test.txt | awk '{if ($4 > 20) print $1" "$3}'
4321 22
1451 36
bld@dev$
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Travis MartinezSmoke JumperCommented:
If the fields are tab delimited then it should be straight forward:

grep Anne <file> | cut -f4

Again, if tab delimited the second one should be:

grep [2-9][0-9]\.[0-9][0-9] <file> | cut -f1

I have a feeling though that your file isn't tab delimited.
0
arnoldCommented:
Grep is a tool to match patterns
As others pointed out other tools, commands need to be used to meet your need.

Your second question
cat fileofdata.txt | awk ' ($4>=20) {print $2,$4 }'
The default when -F is not used to designate the delimiter to ve use to break up the data on a line is white space, which would include combinations of spaces, and I velum E tabs.

The condition is To evaluate whether the last column is greater than 20, iwhen it is the name and the hourly is reported.

Where is this data coming from, it might be better to search through the source if database, or similar....
1
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Linux

From novice to tech pro — start learning today.