Wednesday, February 29, 2012

Grepping for Control Characters

"\t Will Not Work"

Plain and simple, send a ^v before the control character you want. ;)

What happened there?

Say for example you want to grep for lines in a file that have tabs. You've tried grep '\t' yourfile to all avail and it's just not working. Well, you're close, you actually want to send a tab. To do so, use ^v (control + v) and then send an actual tab:
grep '^v[tab button]' yourfile

This seems to be a common question from people and a coworker just dropped in to ask, so here ya go! Cheers!