Skip to content

Instantly share code, notes, and snippets.

@spiculator
Created March 18, 2012 20:07
Show Gist options
  • Save spiculator/2080744 to your computer and use it in GitHub Desktop.
Save spiculator/2080744 to your computer and use it in GitHub Desktop.
tee grep with awk
sergey@eeeteak:/tmp$ awk '{ if( /isok/ ) {print $0 >> "/dev/fd/4"} else {print $0 >> "/dev/fd/5"} }' 4>/tmp/passed 5>/tmp/failed
dgshbkl,hb
sdfbjh,,jhbdfv
cfzxmgvzxfisoksxfgvjhvb
dxfmgvmhv
dsxvjhbisok
sergey@eeeteak:/tmp$ cat /tmp/failed
dgshbkl,hb
sdfbjh,,jhbdfv
dxfmgvmhv
sergey@eeeteak:/tmp$ cat /tmp/passed
cfzxmgvzxfisoksxfgvjhvb
dsxvjhbisok
sergey@eeeteak:/tmp$
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment