You should do egrep for both patterns then.
`/.runme.sh | egrep "ook|eek"
but it seems you need to redirect the each pattern evaluation output to its own file, which grep does not seem to support. Anyone, please correct me if it is possible.
Edit: minaev gave a working example with pee from moreutils, but if pee is missing on your platform, we can still use tee like this. Just play with process substitution.
./runme.sh |tee >(grep ook > ook.txt) >(grep eek > eek.txt)
Example:
[centos@centos scripts]$ ./runme.sh
eekfarapplebin
keeekmajowrwt
keekookjsfskooeek
ook
[centos@centos scripts]$ ./runme.sh | tee >(grep eek >eek.txt) >(grep ook >ook.txt)
eekfarapplebin
keeekmajowrwt
keekookjsfskooeek
ook
[centos@centos scripts]$ cat eek.txt
eekfarapplebin
keeekmajowrwt
keekookjsfskooeek
[centos@centos scripts]$ cat ook.txt
keekookjsfskooeek
ook
[centos@centos scripts]$
pee
appears to do just what I want.sed
andawk
can solve this in 1 process. Withpee
you will start 3 processes. Hack or not, sounds more efficient.