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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

need a guru...I'm an awk-tard

Status
Not open for further replies.

sumgirl

IS-IT--Management
Mar 19, 2003
55
US
I have a working awk statement like so:
awk 'substr($0,815,2)==03{print}' outfile.txt

This statement works and pulls out records that meet have "03" in positions 815 - 816. What I want to do is specify a list of criteria, like ==03,H1,ZZ.

But I can not get this to work correctly. I tried this:
awk 'substr($0,60,1)==/03||H1||ZZ/{print}' outfile.txt
but no dice. Can someone please help? I think I need to use Awk do to the file size and as a requirement I must accomplish this with one command line. This last requirement is a must and out of my control!

Please help, thanks in advance.
-dnix



Running in an AIX environment (in case its relevant.)
 
I just realized I made a type in my second awk statement, I meant to say:
awk 'substr($0,815,2)==/03||H1||ZZ/{print}' outfile.txt

This doesnt solve the probs, just wanted to address for clarity before someone points out the obvious.
-thanks dnix
 

awk 'substr($0,815,2) ~ /(03|H1|ZZ)/{print}' outfile.txt


vlad
+----------------------------+
| #include<disclaimer.h> |
+----------------------------+
 
Thanks...that works!!! I could not find anything so clearly documented on IBM's AIX site!
 
You were trying to match a string literal using awk's
regexp syntax.
It would be better if you picked up &quot;Effective Awk
Programming&quot;, by Arnold Robbins if you plan to work
with awk for any amount of time.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top