All Articles

The ABC's of grep - T

T

Use the -T flag to add a tab before the actual line of content. This flag is most useful when used with a flag that outputs information before the results.

Consider a test.txt file with the following content:

sad
happy
awake
coffee
work
school

Searching for “happy” with the -n flag will output the line number before the actual content results.

$ grep -n "happy" test.txt
2:happy

Adding the -T flag will add a tab between the line number and content:

$ grep -Tn "happy" test.txt
 2:    happy 

Using the -T flag with different flags will act a little differently depending on the output, but just know this flag helps the results look a little cleaner.

Published Nov 20, 2023

I love coffee, coding and writing.