How to grep a tab on Linux?
Posted on In QAHow 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