

Free online course: RHEL Technical Overview.find ~ \( -iname '*jpeg' -o -iname '*jpg' \) -type f -mtime -7 It turns out you've been taking a lot of pictures lately, so let's narrow this down to files that have changed in the last week. Or maybe you'd like to find those oddly named directories so you can rename them later: find ~ \( -iname '*jpeg' -o -iname '*jpg' \) -type d find ~ \( -iname '*jpeg' -o -iname '*jpg' \) -type f But what if you have some directories that end in jpg? (Why you named a directory bucketofjpg instead of pictures is beyond me.) We can modify our command with the -type argument to look only for files. Fortunately, we can combine patterns with an "or," represented by -o. Great! But the 8.3 name scheme is so 1985. find ~ -name '*jpg'īut wait! What if some of them have an uppercase extension? -iname is like -name, but it is case-insensitive. The -name argument allows you to restrict your results to files that match the given pattern. Perhaps you want to find all the JPEG files in your home directory.

So you need to think about what you're trying to locate. You can change the path argument to narrow things down a bit, but it's still not really any more helpful than using the ls command. This probably doesn't help you find what you're looking for.

And since everything is a file, you will get a lot of output to sort through. Will find (and print) every file on the system. In a recent article, Lewis Cowles introduced the find command.įind is one of the more powerful and flexible command-line programs in the daily toolbox, so it's worth spending a little more time on it.Īt a minimum, find takes a path to find things.
