[Trilug-ontopic] [bash] copying `find`ed files across network

Thomas Gardner tmg at pobox.com
Wed May 23 19:23:09 EDT 2012

On 5/23/12, Tom Roche <Tom_Roche at pobox.com> wrote:
> [...]

(Rearranging the order of your original note a little, sorry):

> Why is the raw `find` working, but the same `find` inside `tar` draws
> the 'empty archive' warning (presumably due to *not* finding the files)?

It's a little hard to tell for sure what's really going on because
of all the indirection you've got going on in your script, but if
you only look at the command that is being printed before execution
(which may or may not be exactly what's really being executed ---
quoting is always a little tricky that way) this:

> # case 2: `find` inside `tar`
> * $ ssh t "pushd /work/MOD3EVAL/nsu/boundary/BLD_ddm_saprc07tc ; tar cfvz -
> $(find . -type f | grep -ve 'CCTM\|CVS\|~$\|\.o$')" | tar xvfz -

has quoting issues.  Things like $variable, `command argument` and
$(command argument) are not protected by double quotes.  In other
words, they get evaluated before the command is ever even run.
Therefore, I think that ``find'' is actually running on your local
machine before the ssh process ever starts.

On the other hand, this:

> # case 1: `raw find`
> * $ ssh t "pushd /work/MOD3EVAL/nsu/boundary/BLD_ddm_saprc07tc ; find .
> -type f | grep -ve 'CCTM\|CVS\|~$\|\.o$' | wc -l"
> * /work/MOD3EVAL/nsu/boundary/BLD_ddm_saprc07tc ~
> * 266

doesn't try to protect any embedded commands or variables within the
command from command line evaluation (no $(command arg) or `command
arg` stuff going on in there) .

Make sense?  I'm not always good at explaining this stuff...


More information about the Trilug-ontopic mailing list