[CentOS] CentOS] Remote archiving with tar over ssh
Joshua Hirsh
joshua.hirsh at partnersolutions.ca
Fri Aug 12 21:06:31 UTC 2005
Hi James,
> > tar c $(find / -name \*.conf) | ssh host.com "gzip -c > file.tar.gz"
>
> Thank you very much, this worked. I have two supplementary
> questions. First, what is the significance of the $() construct in
> bash and how does it interact with tar? Does it take the place of
> standard input based on its position in the utility call?
In this command, the $() construct is used to return files via find to the command line for tar. It's most often used to assign variables with the value of returned commands. ie FOO=$(netstat), where by $FOO is now assigned the output of netstat. Since this is a remote command, it's neccessary to do it this way. If you were running this locally only, these two commands would be identical:
tar -cvf foobar.tar `find / -name \*.conf`
tar -cvf foobar.tar $(find / -name \*.conf)
> Second, is there a way to exclude certain file names from matching
> that otherwise do? I have tried:
>
> $(find / -name /*.conf && !*.so.conf)
There sure is, but try something like this instead:
tar c $(find / -name \*.conf -not -name \*.so.conf) | ssh host.com "gzip -c > file.tar.gz"
Cheers,
-Joshua
More information about the CentOS
mailing list