home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #3 / NN_1993_3.iso / spool / alt / lang / awk / 19 < prev    next >
Encoding:
Text File  |  1993-01-24  |  1007 b   |  32 lines

  1. Newsgroups: alt.lang.awk
  2. Path: sparky!uunet!cs.utexas.edu!hellgate.utah.edu!csn!yuma!sgcraw
  3. From: sgcraw@CS.ColoState.EDU (stewart crawford)
  4. Subject: Re: How does one do matching within an if expression?
  5. Sender: news@yuma.ACNS.ColoState.EDU (News Account)
  6. Message-ID: <Jan22.232907.55238@yuma.ACNS.ColoState.EDU>
  7. Date: Fri, 22 Jan 1993 23:29:07 GMT
  8. References: <1993Jan15.125915.5819@cas.org>
  9. Nntp-Posting-Host: beethoven.cs.colostate.edu
  10. Organization: Colorado State University, Computer Science Department
  11. Lines: 19
  12.  
  13. In article <1993Jan15.125915.5819@cas.org> lvirden@cas.org (Larry W. Virden) writes:
  14. >
  15. >$0 ~ /string 1/ {
  16. >        if ( $0 !~ /string 2/)
  17. >            print $0
  18. >        }
  19. >
  20. >but haven't been able yet to figure out the proper syntax.
  21.  
  22.  
  23. I think we need some thought clarification here.
  24. You've got two conditions which, when both satisfied, you want an action.
  25. The "pattern" part of an awk line is where you spell out conditions.
  26. Therefore:
  27.  
  28.     $0 ~ /string 1/  &&  $0 !~ /string 2/        { print $0 }
  29.  
  30. stew crawford.
  31.  
  32.