8.3.1 Basic commands for copying a whole subdirectory
If you need to rearrange file structure, move content including file links by:
Standard method:
# cp -a /source/directory /dest/directory # requires GNU cp
# (cd /source/directory && tar cf - . ) | \
(cd /dest/directory && tar xvfp - )
If a hard link is involved, a pedantic method is needed:
# cd /path/to/old/directory
# find . -depth -print0 | afio -p -xv -0a /mount/point/of/new/directory
If remote:
# (cd /source/directory && tar cf - . ) | \
ssh [email protected] (cd /dest/directory && tar xvfp - )
If there are no linked files:
# scp -pr [email protected]:/source/directory \
[email protected]:/dest/directory
Here, scp
<==> rcp
and ssh
<==> rsh
.
The following comparative information on copying a whole subdirectory was
presented by Manoj Srivastava [email protected]
to
[email protected].