All Articles

The ABC's of grep - L

L

Use the -L flag to list the files that does not contain the search term.

Let’s return back to our simple test.txt file with the following content:

sad
happy
awake
coffee
work
school

Let’s also create a file numbers.txt with different content:

$ echo 123456789 > numbers.txt

In order to see which file does not contain the numbers, run:

$ grep -L 12345 *
test.txt

Want to see the files that do contain the numbers? Use the -l flag:

$ grep -l 12345 *
numbers.txt

Published Nov 8, 2023

I love coffee, coding and writing.