[ale] FGrep matches and non matches to two seperate files

Geoffrey esoteric at 3times25.net
Thu Dec 22 21:47:22 EST 2005


Greg Freemyer wrote:
> Personally I would do it with a 2 line awk script.  awk will only read
> the lines once each.
> 
> I think the below script works.
> 
> ===========
> #!/bin/sh
> 
> 
>>outfile1
>>outfile2
> 
> awk '
> /pattern/ { print >> "outfile1" }
> !/pattern/ { print >> "outfile2" }
> ' inputfile

But you don't need to have two pattern matches, it was an 'if-then-else' 
problem:

/pattern/ {print >> "outfile"; next}
{print >> "outfile1"}

-- 
Until later, Geoffrey



More information about the Ale mailing list