Regex egrep finds .gz but NOT.tar.gz

I need to find all .gz

files, but not .tar.gz

files in a directory, and then send all .gz

files to some_other_command

for processing.

Until now I could:

find . -regextype egrep -regex '.*/*\.gz$|[NOT .tar.gz]' -exec some_other_command -- '{}' '+'

some_other_command

only files are needed .gz

, not .tar.gz

. What should be my part of the [NOT .tar.gz]

regex?

+3


source to share


2 answers


You can use this:



find . -name "*.gz" ! -name "*.tar.gz" -exec some_other_command -- '{}' '+'
       ^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^
       I want        I do not want

      

+8


source


With lookbehind from grep:



find . | grep -P '(?<!\.tar)\.gz' | xargs some_other_command

      

0


source







All Articles