bash muscle (1)

I should build my bash muscle. I’m going to do just that gradually here.

What if I wanted to find files that contain certain text in them? Let’s try the command below.

$ grep -rl 'test' | grep groovy

-r (–recursive) means “Read all files under each directory, recursively. Follow all symbolic links, unlike -r” is what’s in man page for grep.

-l (–files-with-matches) “Suppress normal output; instead print the name of each input file from which output would normally have been printed. The scanning will stop on the first match.

The | grep groovy part filters the files that contains groovy in the file name.

By running the command, you would get a result like the following.


And the file certainly contains the text “test” in it.

This command is kind of like Find in Files in Windows but it’s better with grep capability. Definitely a command to remember.

Leave a Reply

Your email address will not be published.