I have a series of files called:


I want to find all the log files over a certain age, then tar.gz them along with any other file with the same beginning part of the name into an archive.

$ find . -name '20*.log' -ctime +90 -exec 'tar zvcf /var/log/logzip/{}.tgz {}*' \;
find: tar zvcf /var/log/fwlogzip/./2014111test.log.tgz ./2014111test.log*: No such file or directory

However, if I type

tar zvcf /var/log/fwlogzip/./2014111test.log.tgz ./2014111test.log*

by itself, it works fine. So it looks like something is going wrong with the globbing as find passes the command to the shell.

What am I missing?


Why do you have quotes around your tar command? Kill the quotes. You're trying to run the command:

tar zvcf /var/log/fwlogzip/./2014111test.log.tgz ./2014111test.log*

with no arguments

Remember that UNIX commands can have embedded spaces in it.

I can't test this but:

find . -name '20*.log' -ctime +90 -exec tar zvcf /var/log/logzip/{}.tgz {}* \;

should work.

  • It doesn't. Did you test it? – Paul Dec 19 '14 at 9:33

Try once removing quotes around the tar command and also remove * after { }, why you are using * after { }. I have checked it it is working fine.

  • Please read the question again - I am tar-ing multiple files base on the filename found. – Paul Dec 19 '14 at 9:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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