|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Stay one step ahead of the competition. Evaluate and give feedback
on some of the hottest web development tools on the market today.
Make your opinion heard! Click
Here
|
|
#1
|
|||
|
|||
|
Please help with AWK - MATCH function
Hi,
In the example below I am matching on SURNAME, some characters and then a comma. However, because in the line of text SURNAME2 is often before SURNAME (but not always), SURNAME2 is getting picked up twice !!! How can I change the match for SURNAME so that it still does what I want but doesn't include SURNAME2 ?? BEGIN { } { surname = match($0, /SURNAME[^,]*,/); if (surname) output = output substr($0, RSTART, RLENGTH-1); surname2 = match($0, /SURNAME2[^,]*,/); if (surname2) output = output " , " substr($0, RSTART, LENGTH-1); Many thanks for your help. |
|
#2
|
|||
|
|||
|
If you extract the data for SURNAME2 first, change the string SURNAME2 to "xxxxxxxx" you will be able to search $0 for SURNAME????? successfully
|
![]() |
| Viewing: Dev Shed Forums > Operating Systems > UNIX Help > Please help with AWK - MATCH function |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|