THANKS TO ALL WHO RESPONDED TO MY QUESTIONS, YOU'RE LIFE SAVERS...
Original Question:
Hi all,
Is there an easy way to copy files while preserving their original
links?
Thanks to everyone in advance...
ANSWERS:
tar can also be used to move hierarchies with the command:
example% cd fromdir; tar cf - .
| (cd todir; tar xfBp -)
Tada. :)
-James
--
James Neal (neal@ee.pdx.edu) | Microsoft is not the
answer. UNIX S/N Administrator | Microsoft is the
question, EE/CS/ME/CE - Portland State University | NO is the answer.
--=={{ Systems related problems -> cat@cat.pdx.edu }}==--
There are many ways that you can do this, but one of the simplest is
just to tar the files like this:
tar cvf - <source> | (cd <dest_dir>; tar xvf -)
For example, if you are in /tmp and want to copy the contents of
directory "blah" to "/tmp/blah1" preserving links, do it like this:
tar cvf - blah | (cd /tmp/blah1; tar xvf -)
All links will be preserved. When tar tars up a symbolic link,
because the "v" (verbose) is specified, you will see "symbolic link".
If you have any questions, please don't hesitate to ask.
Jason Keltz
jas@cs.yorku.ca
directory/file top copy for example is data
tar cf - data | (cd /new/location ; tar xpf -)
this will copy everything except character files.
Satish
use tar
do "man tar" to read about it
marina
tar and cpio will both work. Here's my favorite technique for copying
dirs:
/bin/find . -xdev -depth -print|cpio -pduml <destination directory>
That copies everything from your current directory on downwards to the
destination you specify. It's how I copy disks.
--
Chris Marble - HMC UNIX Systems Manager, chris_marble@hmc.edu
My opinions are my own and probably don't represent anything anyway.
two ways that are fairly simple:
sun% cd <orig dir> ; tar -cvf - . | ( cd <new dir> ; tar -xvfBp - )
or
sun% cd <new dir> ; ufsdump 0f - <orig dir> | ufsrestore -rf -
the ufsdump method also preserves time stamps. in both method, the
owner of the link will always be root.
to change the owner you can use several methods including:
sun% cd <new dir> ; find . -type l -print -exec chown ??? {} \;
have fun.
Hello Toby,
just use rdist.
Bye Richard.
--
Richard Aures
Unix System Support
Fon: +49(0)172 6527573 Fax: +49(0)911 9758203 Web:
http://www.erlangen.netsurf.de/richard.aures
You can use this tar - comand
cd <source>
tar -cf - . | (cd <target> ; tar -xvfl -)
The option -l , is the 'copy link' option.
Trond Isaksen
trond.isaksen@nopow.abb.no
tar preserves links
cd fromdir
tar cf - * | (cd todir;tar xf -)
tony@csc20.essex.ac.uk (Lawson A S)
By links do you mean "symlinks" and "hard links"? "tar" can do this
eg
( cd /old/directory ; tar cf - ) | ( cd /new/directory ; tar xvfp - )
Stephen Harris <sweh@mpn.com>
In Bourne shell, the most reliable way to do this is: (cd $SRCDIR;tar
cf - .)|(cd $DEST;tar xvf -)
replacing $SRCDIR and $DEST with the full pathnames to the source and
destination directories respectively.
---Avi---
Try using tar, for example:
tar cvf - my_directory | (cd ../my_new_directory; tar xf -)
It will copy all files under my_directory to ../my_new_directory,
preserving all links in it
Regards,
Fernando Frota Redigolo
fernando@larc.usp.br
I would use "tar" and "dd"
Examples:
______________________________________________________________________
__________ ___
Note: The following commands are for tape device /dev/rst0. If you are
using a
second tape device, i.e., 1/4" or 8mm, replace /dev/rst0 with
/dev/rst1.
----------------------------------------------------------------------
---------- ---
#
#---reads writes from: local 1/4" tape to 1/4" remote tape. #
% dd if=/dev/rst0 bs=126b | rsh <remotesystemname> dd of=/dev/rst0
bs=126b
#
#---reads and writes from: remote tape to local tape. #
% rsh <remotesystemname> dd if=/dev/rst0 bs=126b | dd of=/dev/rst0
bs=126b
#
#---reads and writes from: local disk to remote tape. #
% tar cvfb - 20 <filenames> | rsh <remotesystemname> dd of=/dev/rst0
obs=20b
#
#---reads ands writes from: remote tape to local disk. #
% rsh <remotesystemname> dd if=/dev/rst0 bs=126b | tar -xvpBfb - 126
<filenames>
#
#---reads ands writes from: remote tape to local disk. (different
diredctory) #
rsh <remotesystemname> dd if=/dev/rst0 bs=126b | (cd <newdir> ; tar
-xvpBfb - 126)
#
#---reads ands writes from: remote disk to local tape. #
% rsh <remotesystemname> tar cvfb - 126 <filenames> | dd of=/dev/rst0
obs=126b
#
#---reads and writes from: local tape to remote disk. #
% dd if=/dev/rst0 bs=126b | rsh <remotesystemname> | tar -xvpBfb - 126
<filenames>
#
#---reads and writes from: remote disk to local disk (same directory).
#
% rsh <remotesystemname> tar -cvfbB - 1000 <filenames> | tar -xvfbBp -
1000
#
#---reads and writes from: remote disk to local disk (different
directory). #
% rsh <remotesystemname> cd <directory> ; tar -cvfbB - 1000
<filenames> | (cd <newdir> ; tar -xvfbBp - 1000)
#
#---reads and writes from: local disk to local disk (different
directory). #
cd <directory>
tar -cvfbB - 1000 <filenames> | (cd <newdir> ; tar -xvfbBp - 1000) #
#---reads and writes from: local disk to remote disk (different
directory). #
cd <directory>
tar -cvfbB - 1000 <filenames> | rsh <remote-system> "(cd <newdir> ;tar
-xvpBfb - 1000)"
See tar(1) and dd(1). Also see bar(1).
Mark Hargrave
------------------------------------------
Mark Hargrave, Sr. Unix Systems Manager Lockheed Martin Manned Space
Systems
PO Box 29304 Mail Stop: 3414
New Orleans, LA 70189
Phone: 504-257-1242
E-Mail: meh@wisdom.maf.nasa.gov
------------------------------------------
Hi Toby,
you can use commands like the following:
find <files-to-copy> -depth -print | cpio -pdm <destination-dir>
or, if needed remote:
find <files-to-copy> -depth -print | cpio -o | rsh <desthost> 'cd
<destination-dir> ; cpio -idm'
Hope that helps
Kind Regards - Jens Fischer
I User : Jens Fischer
Department : DV-Anwendungsentwicklung Technik
I N A Company : INA Werk Schaeffler KG
Address Industriestrasse 1-3
A D 91074 - Herzogenaurach
Phone : (+49)9132-823262
FAX : (+49)9132-824953
e-mail : fischjns@kat.ina.de
you can do it either with dump or cpio. With cpio do it as follows
find . -depth -print | cpio -pdmv newdir
Notice you must be in the old directory when you run it and newdir
must be there
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
= Mike (Mehran) Salehi mrs@cadem.mc.xerox.com (716) 422-2725
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
=
Sure. Use tar (or "bar" or Gnu's tar, "tar") like this:
(cd /sourcedir;tar cf - file1 file2 dir1 dir2) | (cd /targetdir; tar
xpf -)
The "p" flag also preserves permissions. You can add the "v" flag to
either invocation of tar if you want to watch its progress. And
obviously, if you're already in the sourcedir or targetdir, you don't
need one of the "cd" commands.
---Rsk
Rich Kulawiec
rsk@itw.com
This archive was generated by hypermail 2.1.2 : Fri Sep 28 2001 - 23:11:42 CDT