[TriLUG] Moving a subdirectory tree

Benjamin Reed ranger at befunk.com
Sun Feb 3 09:50:06 EST 2002


Mike Broome [mbroome at employees.org] wrote:
> "cp -a" worked for me recently.  (-a is shorthand for -dpR.  It's the -p
> that preserves the timestamps.)

Yup, cp -a works great; another favorite of mine is a "tar copy":

# cd /usr/share
# tar -cf - . | (cd /mnt/new/share; tar -xvf -)

...it's such a spiffy unixy hack I just can't help almost giggling every time
I do it.  =)  The advantage of this is that you can do freaky rsync-like stuff
over SSH, or other nifty things:

# cd /usr/share
# ssh -C ben at somehost 'cd /usr/share; tar -cf - .' | tar -xvf -

(it depends on the type of data you're copying, -C is often *slower*
with a tar copy like this)

Yet another possibility is rsync.  rsync does not have to be run over a
network, it can be used to sync local directories:

# rsync -av /usr/share /mnt/new/share

-- 
Ben Reed a.k.a. Ranger Rick (ranger at befunk.com)
http://defiance.dyndns.org/ / http://radio.scenespot.org/
Frankenstein was the creator -- not the monster.  It's a common
misconception, held by all truly stupid people. -- Kryten



More information about the TriLUG mailing list