tags:

views:

72

answers:

1

Hi guys,

I have been trying to work out the syntax for this command:

grep ! error_log | find /home/foo/public_html/ -mmin -60

or

grep '[^error_log]' | find /home/baumerf/public_html/ -mmin -60

I need to see all files that have been modified except for those names error_log.

Reading about it here, but only one NOT regex there: http://www.robelle.com/smugbook/regexpr.html

Advice greatly appreciated!

JG

+3  A: 

grep -v is your friend

grep --help | grep invert
-v, --invert-match select non-matching lines

Also check out the related -L (the complement of -l).

-L, --files-without-match only print FILE names containing no match

Motti
Thanks for the reply! Tried this and grep --invert-match 'error_log' | find /home/foo/public_html/ -mmin -60runs for several minutes and outputs/home/foo/public_html/contest/error_log/home/foo/public_html/error_logetc...whereas grep ! error_log | find /home/foo/public_html/ -mmin -60 produces that same output and finishes in 2 seconds.What am I doing wrong? Also tried it with -v instead of --invert-match
jerrygarciuh
@jerrygarciuh, You have the `find` and the `grep` in the wrong order, it should be `find /home/foo/public_html -mmin -60 | grep -v error_log`
Motti
Oy. Thank you! Much obliged.
jerrygarciuh