LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   the MATCH function in awk (https://www.linuxquestions.org/questions/linux-software-2/the-match-function-in-awk-891074/)

alexandnpu 07-11-2011 06:59 AM

the MATCH function in awk
 
printf "%s, %d\n", $3, match(data, $3);


that is what i use in my awk script.

i found that it cannot match the $3 which has "()" in it.

could you give me some help? i need it to match the parenthesis.

thanks.

PS: i am using GNU Awk 3.1.5

David the H. 07-11-2011 08:44 AM

1) Please use [code][/code] tags around your code, to preserve formatting and to improve readability.

2) Please include a real, representative example of the input to be processed, so we know exactly what we're supposed to be dealing with, and don't have to guess.

3) From what I understand of the match function (and to tell the truth, I'm not too familiar with it), you appear to have the syntax wrong, at least, and are perhaps using it completely inappropriately.

http://www.gnu.org/software/gawk/man...Functions.html

4) From all of this, I get the suspicious feeling that this is really an XyProblem. Perhaps you should explain exactly what you are trying to accomplish, and why.

grail 07-11-2011 10:04 AM

Please for the love of god read David's signature on how to ask a question. I am sorry but that was about as useful as giving me 42 and asking for the question.

1. What does the data look like

2. what is in the variable data

3. what is in the field $3

4. what is the delimiter? if not white space then your data could look like just about anything.


...


All times are GMT -5. The time now is 02:34 AM.