Results 1 to 4 of 4
Hi,
I have an if statement in a awk script that will not execute because it generates this error:
fatal: Unmatched ( or \(: /(/
for this if statement :
...
- 06-15-2009 #1
Awk pattern Matching Problem
Hi,
I have an if statement in a awk script that will not execute because it generates this error:
fatal: Unmatched ( or \(: /(/
for this if statement :
if ($i ~ /\x28/)
Now I know the problem is \x28 translates to the parenthesis "(" and causes a syntax error but I have no idea how to phrase this so I can match $i to the hex value x28.
I search Google and found nothing, the closest I got was a Fedora book that states "You can quote any special character(but not a digit or a parenthesis) by preceding it with a backslash" - A Practical Guide to Red Hat Linux, Sobell...This quote doesn't sound to promising...
...Gerard4143
So does anyone know a way around this?Make mine Arch Linux
- 06-15-2009 #2Linux Newbie
- Join Date
- Mar 2009
- Posts
- 228
If you have to use the hex value then:
But why not just:Code:if ($i ~ /[\x28]/)
Code:if ($i ~ /\(/)
- 06-15-2009 #3
Tried that...and it won't match...
Actually my apologies...it does match but I have to put it at the beginning of the if else if statements...for it to match. I think my problem isn't so much the matching pattern - $i ~ /\(\ - as it is the length of my if else if... statements.
...Gerard4143Make mine Arch Linux
- 06-15-2009 #4
So both you ideas worked in these simple scripts....now just to figure out why its failing in the multi level if else if statement....Thanks Gerard4143
Code:awk 'BEGIN {FS = "";} {for i = 1; i <= NF; ++i}{if ($i ~ /\(/) {print$i} }' filename awk 'BEGIN {FS = "";} {for i = 1; i <= NF; ++i}{if ($i ~ /[\x28]/) {print$i} }' filenameMake mine Arch Linux


Reply With Quote
