![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Regular Expressions in If clause | Raamc | Shell Programming and Scripting | 3 | 12-30-2008 11:01 AM |
| Conditonal clause in expect. | akbar | Shell Programming and Scripting | 1 | 05-13-2008 07:28 PM |
| if clause | palmer18 | UNIX for Dummies Questions & Answers | 3 | 08-08-2007 09:22 AM |
| building a SET clause in shell script | shalua | Shell Programming and Scripting | 14 | 04-10-2007 06:34 PM |
| if clause in AWK END block not working. | satnamx | Shell Programming and Scripting | 1 | 04-21-2006 06:29 AM |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
having trouble with using if clause in AWK
The goal:
I have a list of people in teams. The list looks something like this $1 = Job Position (marketing, IT, PR) $2 = Name $3 = Team Name $4 = Targeted member (somebody in field 2 targets somebody else) $5 = Employment Status (full time/part time/etc) The idea is to search through the second field and spit out the lines that have the search results. The problem is since everybody who is in field 2 is also in field 4 (since everybody is targetted at least once) I'm getting double the results I want. I just want to search through the second field. I'm trying to have a simple line of code that will look into the second field of a list, and use a regular expression to search that field and print it out. This is what I have, which I think should work, but it won't, and i'm fresh out of ideas. Any assistance would be helpful. like awk -F, ' /John/{print $0}' myfile does the trick, it finds any line with john, fantastic. HOWEVER, my goal is to find all the Johns in ONE field. awk -F, ' { if($4=="John") print $0} ' myfile now this line of code should work (and returns nothing even when the first line returns the correct entries) but even if it did, it finds precisely John, where i'd also like to find any name that might make up John, ie, ohn. I know that sounds like a grep problem but i'm having trouble dealing with grep even more then awk which i'm sure is how to go about doing this problem. any and all help greatly appreciated. |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|