The smart find and grep utilities

search_compfind and grep are most useful friends when you are connected to an unfamiliar remote Linux box via a terminal or trying to find some specific files or a particular string in any file.
For example, to find all movies matching the name “evening”, of type MKV and size between 650MB to 750MB in the current directory recursively, you can run:

# find . -iname '*evening*.mkv' -size +650M -size -750M

To find the c files accessed and modified in the last 10 minutes:

$ find /home/david -amin -10 -name '*.c'
$ find /home/david -mmin -10 -name '*.c'

Look for string in .c and .cpp files:

$ grep -nr string --include=*.c --include=*.cpp

Check out the man pages for many more useful options.

One thought on “The smart find and grep utilities”

Comment

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 )

Twitter picture

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

Facebook photo

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

Google+ photo

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

Connecting to %s