LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 07-11-2011, 06:59 AM   #1
alexandnpu
LQ Newbie
 
Registered: Jul 2011
Posts: 2

Rep: Reputation: Disabled
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
 
Old 07-11-2011, 08:44 AM   #2
David the H.
Bash Guru
 
Registered: Jun 2004
Location: Osaka, Japan
Distribution: Arch + Xfce
Posts: 6,852

Rep: Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037
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.
 
Old 07-11-2011, 10:04 AM   #3
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 10,008

Rep: Reputation: 3193Reputation: 3193Reputation: 3193Reputation: 3193Reputation: 3193Reputation: 3193Reputation: 3193Reputation: 3193Reputation: 3193Reputation: 3193Reputation: 3193
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.


...
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] How would I use awk or sed to match this? ted_chou12 Programming 7 04-08-2011 04:27 AM
What should some Regex match in awk? sebelk Programming 7 11-20-2009 06:38 PM
awk , I need help for awk, just a display function mcandy General 1 12-15-2008 12:21 PM
RE in commands like match() inside awk. stalin.varanasi Linux - Newbie 2 12-12-2007 11:31 PM
grep/sed/awk - find match, then match on next line gctaylor1 Programming 3 07-11-2007 08:55 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 08:13 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration