Awk: Need to evaluate a string and delete line where the string matches

We are running a legacy front-end system running in HP-UX 10.20.  The system produces an ASCII interface file that is uploaded into our GL system.  The interface file is positional with no delimiters as seen in this snippet:

C90-00-00-1441-0000000000000000494102008/01/11UNBILLED RECEIPTS
C90-00-00-1441-0000000000000005504002008/01/11UNBILLED RECEIPTS
C90-00-00-5165-0000000000000000000002008/01/11UNBILLED RECEIPTS

I want to evaluate the transaction amount of each line with is the 15 characters in positions 22 through 37.  If the string is 000000000000000, as in line three of my sample, I want to reject the line.  The accountants seem to think It's important however that only the lines with zero-dollar amounts are rejected ;).  I currently use AWK to substitute certain cost center portions.  I know CUT -c15-37 would extract the range I am looking for.  

How can this be accomplished using AWK or some other tool that one would find in an older UNIX environment?  

Thanks for reviewing this question.
Who is Participating?
TintinConnect With a Mentor Commented:
awk is fine, but sed is just as easy

sed "/0000000000000002[0-9][0-9][0-9]\//D" file

ptewAuthor Commented:
Wow, thanks for the fast response.  It works!  

Now, would you explain it to me?
Without knowing what values columns 15-22 could contain, I assumed they may not necessarily be zeros, so I've specified sed to delete any line that matches 15 zeros followed by 4 digit date ending with a /.

Does that make sense?
ptewAuthor Commented:
It makes sense now.  The /0000000000000002[0-9][0-9][0-9]\/ is the search string where the [0-9] makes it match any year from 2000 to 2999 (hopefully we will have upgraded by then) and \/ is the slash after the year.  The /D tells it to delete the line when matching.  Thanks!
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.