[Novalug] Having problems copying data using cp over nfs

donjr djr1952 at hotpop.com
Tue Jun 19 17:50:25 EDT 2007


Both "-" in this case tell 'tar' to read/write to stdout.

The first part
  (cd $WRK && tar cf - . )

says change to directory $WRK "cd $WRK" {note $WRK is read from the
environment} if successful then create(c) a tar of the current
directory(.) and all below it and write it to STDOUT(the f -).

Then PIPE(|) to the second part
(cd /mntpoint/email/$WRK && tar xvfp - )

says change to directory /mntpoint/email/$WRK 
if successful then READ the tar-archive from STDOUT(the f -) and
extract(x) to the current directory preserving-permissions(p) and be
verbose(v) about it.

Do note that Przemek Klosowski showed a much better way to do the above,
if you can assume that the GNU tar is the tar that will be used:
  { The -C option isn't a standard option of tar. }

tar -C /home/jhart -cf - Maildir | tar -C /mntpoint/email/home/jhart -xf -

The main differences are:
  tar is doing the "change directory" -C /{directory path} internally 
  and the output 'tar' will create the directory Maildir if it doesn't
exists.

Note the lone "-" still have the same meanings.

See the man page "man tar" for further details, as the "-" is a
documented tar parameter and/or subitute for /dev/stdin or /dev/stdout
depending on how it is used.


On Tue, 2007-06-19 at 16:48 -0400, Jay Hart wrote: 
> Don,
> 
> I don't understand the below commands. Here is what I think it does:
> 
> 1. change to WRK dir and tar everything in it
> 2. pipe the output from #1 to the dir shown in the 2nd parens and untar it
> 
> What does the "-" do?
> 
> 
> > Try the command combo:
> >  $ WRK="/home/jhart/Maildir"
> >  $ (cd $WRK && tar cf - . ) | (cd /mntpoint/email/$WRK && tar xvfp - )
> >
> > This uses 'tar' {the tar archiving utility} to get those "invisible"
> > files and directories, plus it may even be a little faster then a simple
> > cp.

--
--
  Don E. Groves, Jr.

$ /usr/games/fortune : You will inherit millions of dollars.




More information about the Novalug mailing list