![]() |
|
|
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. |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
Help with awk
I want to search $2 to see if the first letter contains W or the second letter contains W, but my code prints out nothing. This is sample data from dataFile.txt Code:
northwest NW Joel Craig 3.0 .98 3 4 western WE Sharon Kelly 5.3 .97 5 23 southwest SW Chris Foster 2.7 .8 2 18 Code Code:
nawk '{ if (($2 == "W.") || ($2 == ".W")) print $2, $3, $4, $1}' dataFile.txt
When I specify ($2 == "NW") I get a print out of the line containing "NW", but when using the symbol to match any character....ex. ($2 == ".W"), I don't get anything. Help! Thanks |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|