[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[ale] FGrep matches and non matches to two seperate files
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