On 15/01/12 13:14, (Ted Harding) wrote:
On 15-Jan-2012 Laurie Brown wrote:
On 14/01/2012 22:33, (Ted Harding) wrote:
[SNIP]
That looks hopeful. I'll give it a try in the morning (once my caffeine levels are up). Ted.
I'd advise using tar too. These are from my notes:
---- cut here ---- #### To copy a directory tree with tar:
cd fromdir; tar cf - . | (cd todir; tar xfBp -)
copy all files and subdirectories in "fromdir" to "todir". Note target dir must exist. Note the use of "-" with pipe. N.B. this is how you move a directory between discs.
#### To copy all of the files and subdirectories in the current working directory to the #### directory /target, use:
tar cf - * | ( cd /target; tar xfp -) ---- cut here ----
Obviously, you need to add in the exclude part from Keith's suggestion.
Cheers, Laurie.
One question about this kind of approach. The above pipe is written as though the "tar cf - *" part is completed before the output is piped to the "( cd /target; tar xfp -)" part (I'm guessing this because of the "cd" element of the second part). So, supposing the tar archive from "tar cf - *" is very big (as it would be in this case, far exceeding the RAM and swap space), would that cause problems?
Ted.
It won't cause a problem because the two halves of the operation take place in parallel. When the shell sees the pipe (|) it will use fork to start the left and right hand halves as separate processes. The left half will not touch the current directory and will build a TAR archive of the files and send this to standard out (the pipe). On the right hand side the cd will execute first thus changing the current directory of the process executing the right hand side. As the current directory is specific to process this will not affect the left hand side or the shell. After doing that tar will read the archive from standard input (the pipe) and unpack it into the new directory.