Friday 18 January 2013

How to grep a variable in bash?


export var='chr1'
grep -P ^$var'\t' file.to.grep

This will grep the lines that begin with chr1 followed by a tab. This ignores cases as chr11 or chr19