|
|
Unix Guru Says: Use xtar
By default "cp" will follow or dereference symbolic links. That is, a "cp -R" will copy the file that the link points to instead of the link. Some versions of "cp" allow the "-d" or "--no-dereference" flag to prevent this, however I got in the habit of using "tar" instead years ago: To copy a directory I simply do this: tar cvf - directory/ | (cd /new/location; tar xvf - ) "cvf -" means compress the directory verbosely into the file called - (standard out). The standard out is then piped ("|") into a compound command surrounded by parentheses, which first changes directories and then extracts data from standard in ("-"). What's interesting is, now that Unix and MacOS have merged, the same problem exists with resource forks being omitted by "cp -R". Thus to recursively copy a directory, preserving all links and resource forks, one can use the above command, substituting "xtar" for "tar". To copy directories between machines, this command is exceptionally useful (substitute "xtar" if resource forks are present): tar cvf - directory/ | ssh user@host '(cd /some/path; tar xvf - )' Instead of all those GUI "ssh" programs, I run this from the command line daily to move files between different machines. Michael.
Minor nit [Re: Unix Guru Says: Use xtar]
The -c option of tar doesn't stand for Compress, but rather for Create. Normally, tar is used for lisTing the contents of (-t), eXtracting from (-x), or Creating (-X) a tar (Tape ARchive) file. The compression flags are -z for gZip or -j for bzip2 (go figure). |
SearchFrom our Sponsor...Latest Mountain Lion HintsWhat's New:HintsNo new hintsComments last 2 daysNo new commentsLinks last 2 weeksNo recent new linksWhat's New in the Forums?
Hints by TopicNews from Macworld
From Our Sponsors |
|
Copyright © 2014 IDG Consumer & SMB (Privacy Policy) Contact Us All trademarks and copyrights on this page are owned by their respective owners. |
Visit other IDG sites: |
|
|
|
Created this page in 0.05 seconds |
|