Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Counting quotes 1

Status
Not open for further replies.

columb

IS-IT--Management
Feb 5, 2004
1,231
EU
Ok, so I've got the
Code:
Syntax error at line 165 : `"' is not matched.
message. What would make my life so much simpler would be if I had a script (awk?) which counted quotes per line and flagged any where the number of quotes was uneven.

Any ideas?
Should this be in the awk forum?

On the internet no one knows you're a dog

Columb Healy
 
build on this snippet?

[tt]awk '{
CH="\""
occ=0;
while (y=index($0,CH))
{
occ++;
y++;
$0=substr($0,y);
}
if (occ)
print "line " NR ": " occ " double quotes"
}' /path/to/your/script[/tt]


HTH,

p5wizard
 
Thanks p5wizard

changing
if (occ)
to
if (occ%2)
gave me exactly what I wanted and saved hours of searching by eye.


On the internet no one knows you're a dog

Columb Healy
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top