Article View: alt.lang.awk
Article #17Re: How does one do matching within an if expression?
From: stewart crawford
Date: Fri, 22 Jan 1993 23:29
Date: Fri, 22 Jan 1993 23:29
18 lines
1036 bytes
1036 bytes
In article <1993Jan15.125915.5819@cas.org> lvirden@cas.org (Larry W. Virden) writes:
>
>$0 ~ /string 1/ {
> if ( $0 !~ /string 2/)
> print $0
> }
>
>but haven't been able yet to figure out the proper syntax.
I think we need some thought clarification here.
You've got two conditions which, when both satisfied, you want an action.
The "pattern" part of an awk line is where you spell out conditions.
Therefore:
$0 ~ /string 1/ && $0 !~ /string 2/ { print $0 }
stew crawford.
Technical Details
Message-ID:
<Jan22.232907.55238@yuma.ACNS.ColoState.EDU>Path:
arc1-ca.pugleaf.net!sparky!uunet!cs.utexas.edu!hellgate.utah.edu!csn!yuma!sgcrawReferences:
<1993Jan15.125915.5819@cas.org>Show Full Headers
Complete Article Headers
Newsgroups: alt.lang.awk Path: arc1-ca.pugleaf.net!sparky!uunet!cs.utexas.edu!hellgate.utah.edu!csn!yuma!sgcraw From: sgcraw@CS.ColoState.EDU (stewart crawford) Subject: Re: How does one do matching within an if expression? Sender: news@yuma.ACNS.ColoState.EDU (News Account) Message-ID: <Jan22.232907.55238@yuma.ACNS.ColoState.EDU> Date: Fri, 22 Jan 1993 23:29:07 GMT References: <1993Jan15.125915.5819@cas.org> Nntp-Posting-Host: beethoven.cs.colostate.edu Organization: Colorado State University, Computer Science Department Lines: 19