How to grep a tab on Linux?

How to grep a tab on Linux? Including ‘t’ seems not working.

grep can grep tabs. The problem is likely the tab is not passed to grep.

If you are using Bash, you can use ANSI-C quoting to pass the “tab” to grep:

$ grep $'t' file.txt

Or, use Perl-style regex (only for GNU grep) to grep tab:

$ grep -P 't' file.txt
Answered by Eric Z Ma.

Eric Z Ma

Eric is a father and systems guy. Eric is interested in building high-performance and scalable distributed systems and related technologies. The views or opinions expressed here are solely Eric's own and do not necessarily represent those of any third parties.

Leave a Reply

Your email address will not be published. Required fields are marked *