How to grep a tab on Linux?

How to grep a tab on Linux? Including '\t' seems not working.

asked Aug 3, 2016 by anonymous

1 Answer

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 Oct 10, 2016 by Eric Z Ma (44,280 points)

Please log in or register to answer this question.

Copyright © SysTutorials. User contributions licensed under cc-wiki with attribution required.
Hosted on Dreamhost

...