I have a simple question, yet I can't find or solve the answer. I want to make a tar archive, but I want to exclude some files from it using regular expression.
Example of the file to exclude is this: 68x640X480.jpg
I have tried this with no luck:
tar cvf test.tar --exclude=[0-9]+x[0-9X]+\.jpg /data/foto
Can anybody help ?
Best Answer
You can use some additional tools like
find
andegrep
:The drawback of the above mentioned method is that it will not work for all possible file names. Another opportunity is to use the built-in exclude functionality of
tar
:Unfortunately the second method does not work with regular expressions, but only with wildcards.