linuxnippet #2: Finding files in command line

Ever need to find a file that contains some text? Hate trying to remember how to do it so you google it all the time? This post is one I reference often. I do not recommend spending your valuable brain-space on useless info. Just remember how to find the answer and you’ll be golden.

This one is a quickie because it’s mainly for me to remember:

find . -type f -exec grep -l "seting" {} +
find /etc/ -type f -name "*.conf" -print0 | xargs -I {} -0 grep "nameserver" "{}"
find /path/to/dir -type f -print0 | xargs -0 grep -l "foo"

Hope this helps!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s