Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Please look at these two commands:

find ~/{Documents,Desktop,Downloads,Music,Videos} -mmin -120 -type f
find . ! -path "*opera*" ! -path "*mozilla*" ! -path "*google-chrome*" -mmin -120 -type f

While the first tells find to give results relating to specific folders, the second does the opposite. But is there a way to make the second command more compact or does ! path have to precede each folder?

The OS is Lubuntu 12.10.

share|improve this question
up vote 1 down vote accepted

You can use GNU find regular expressions (non standard extension):

find . -regextype posix-extended ! -regex '.*(opera|mozilla|google-chrome).*'

You can maybe use a different (more efficient) -regextype, I didn't check.

Chris Down's solution is not exactly the same thing as your second find command because it does not exclude your pattern from subdirectories (it would still find something like ./somedir/some-mozilla-dir).

The above command does not have this limitation.

share|improve this answer
Thanks for pointing out the limitation in my command, I missed it. – Chris Down Mar 26 '13 at 15:23
@ChrisDown You're welcome :) However, using zsh, something like setopt extendedglob and then **/*~*opera*~*mozilla*~*google-chrome* should match what you want to (~ means exclude). – Totor Mar 26 '13 at 18:12

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.