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

stupid shell tricks, 2015 edition



So I had a situation where I wanted to copy some files from some of my
servers to my local system to examine them.  Finding the files required
a rather long find(1) incantation.  Now I knew that I could quote
arguments to rsync in order to have the remote shell expand the
arguments, like this:

  rsync -avP remote:'*.conf' .
  rsync -avP remote:'{file1,file2}' .

I wondered if I could pass other things that would be expanded by the
remote shell.  I tried something like this:

  rsync -avPR remote:'$( find /etc/yum* -type f \( -name "*.conf" -o -name "*.repo" \) )' .

Amazingly enough, it works.  (The "-R" preserves the path to the remote
files, so in the example above you end up with ./etc/yum/ and
./etc/yum.repos.d/.)

So BTW, while this was a novel idea to me, it turns out it wasn't an
original idea.  I found posts online where people were using the same
trick.  :-)

Steve
-- 
steve@silug.org           | Southern Illinois Linux Users Group
(618)624-4440             | See web site for meeting details.
Steven Pritchard          | http://www.silug.org/

-
To unsubscribe, send email to majordomo@silug.org with
"unsubscribe silug-discuss" in the body.