Sign up ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It's 100% free, no registration required.

While comparing 2 fairly big directories using diff -rq .... I want to exclude certain file types like 'tar.gz' or 'error_log'.

How do I do that?

share|improve this question

1 Answer 1

up vote 3 down vote accepted

GNU diff has options for doing this (see manual page):

   -x, --exclude=PAT
          exclude files that match PAT

   -X, --exclude-from=FILE
          exclude files that match any pattern in FILE

The pattern in each case is a glob (* for any number of characters):

diff -rq -x '*.tar.gz' -x '*error_log' foo bar

See for example:

share|improve this answer
    
Thanks! Should have seen the '-- help' option. – Ramnath 2 days ago

Your Answer

 
discard

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.