>On Fri Aug 12 17:14:00 UTC 2005 Paul Heinlein heinlein at madboa.com wrote:> > How about > > 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? Second, is there a way to exclude certain file names from matching that otherwise do? I have tried: $(find / -name /*.conf && !*.so.conf) and several variants without any success. I am not using rsync, yet, due to lack of familiarity with it and a pressing need to get something working now. Once the essentials are in place then I will look at alternatives. Regards, Jim -- *** e-mail is NOT a secure channel *** James B. Byrne mailto:ByrneJB.<token>@Harte-Lyne.ca Harte & Lyne Limited http://www.harte-lyne.ca 9 Brockley Drive vox: +1 905 561 1241 Hamilton, Ontario fax: +1 905 561 0757 Canada L8E 3CE delivery <token> = hal
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
Donald Murray, P.Eng.
2005-Aug-12 21:10 UTC
[CentOS] CentOS] Remote archiving with tar over ssh
Hi James, On 8/12/05, James B. Byrne <ByrneJB at harte-lyne.ca> wrote:> > > > On Fri Aug 12 17:14:00 UTC 2005 Paul Heinlein heinlein at madboa.com > wrote: > > > > > How about > > > > 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?The $() construct is command substitution. You often see it as a pair of backticks ``. In your case, the "tar c" command is followed by the output from the find command. See the following for more info: http://www.tldp.org/LDP/abs/html/commandsub.html> > Second, is there a way to exclude certain file names from matching > that otherwise do? I have tried: > > $(find / -name /*.conf && !*.so.conf) > > and several variants without any success. >You could do this in at least two ways: $( find / -name /*.conf | grep -v "*.so.conf" ) $( find / -name /*.conf -not -name *.so.conf) The former ignores any line endingin in .so.conf; the latter uses native find functionality.> I am not using rsync, yet, due to lack of familiarity with it and a > pressing need to get something working now. Once the essentials are > in place then I will look at alternatives. > > Regards, > Jim > > -- > > *** e-mail is NOT a secure channel *** > James B. Byrne mailto:ByrneJB.<token>@Harte-Lyne.ca > Harte & Lyne Limited http://www.harte-lyne.ca > 9 Brockley Drive vox: +1 905 561 1241 > Hamilton, Ontario fax: +1 905 561 0757 > Canada L8E 3CE delivery <token> = hal > _______________________________________________ > CentOS mailing list > CentOS at centos.org > http://lists.centos.org/mailman/listinfo/centos >