[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: Help using find command



Rob Myroon wrote:
Hi list,

I am trying to tar up all the openoffice files on my server using the find command. The command I have come up with only tars the last file found by the find command.

# find . -regex '.*\(odt\|ods\|sxc\)$' -exec cvzf /root/openofficefiles.tar.gz {} \;

Looking at the man page, it isn't really clear that exec doesn't work how you probably think it works.

What's happening is, each file found is getting a separate tar instance run on it. That is, say 'find' finds two files a.odt and b.odt. First exec runs 'tar cvzf /root/openofficefiles.tar.gz a.odt' then exec runs 'tar cvzf /root/openofficefiles.tar.gz b.odt'.

> Can someone tell me how to make this work? (I realize that there are
> more openoffice extensions.)

I would suggest trying:

tar -c /root/openofficefiles.tar && find . -regex 'fancy-regex-foo' -exec tar -rv {} \;

This will create the empty archive, then find the files and append them one-at-a-time to the end of the tarfile. It may be possible to append to a zipped tar archive, but I am not certain.

Reid

Attachment: smime.p7s
Description: S/MIME Cryptographic Signature


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]