Help me understand -P option for cp
According to the man page, cp -P source DIRECTORY "append source path to DIRECTORY". I am trying to understand how this is different from cp -R source dest. For example if I have the following structure:
/mydata/OpenOffice/(files) /mydata/music/(files) /mydata/other/(files) and I execute the following command cp -R /mydata /mybackup I end up with /mybackup/OpenOffice/(files) /mybackup/music/(files) /mybackup/other/(files) If I execute cp -R /mydata /mybackup I get a message "omitting dirctory /mydata" and no files are copied. Obviously I do not understand what the -P option is for. TIA, Ken |
Quote:
Regarding the -P option, it tells to copy the parent directories of the source if they are specified on the command line (just the path, not the entire directory tree and its files). Examples: without -P: Code:
$ cp -R /home/user/somedir/ destination/ Code:
$ cp -R -P /home/user/somedir/ destination/ Code:
$ cp -R -P somedir/ destination/ Code:
-P, --no-dereference Code:
--parents |
Thanks colucix! When I read you post and shifted my brain into gear with respect to "parent directory" the operation of the --parents became clear. I was going to do a little testing however, two of my file systems (750 GB and 1 TB were missing :eek:
My Ubuntu 9.10 64 bit system goes into standby as expected about 85% of the time, logs me out instead about 14% of the time and locks up the other 1% of the time. In the last situation I have no option but to power off and restart. This time it failed to mount the 1 TB hard drive and a manual mount attempt said it was already mounted or the mount point was busy. Umount said it was not mounted. Deleting the mount point and recreating it did nothing. Unplugging the hard drive and booting up caused the same problem with the 750 GB drive. Time to upgrade to 10.04 I am thinking. Booted from a CD and fsck the drives - they are OK. Then I made a g4l snapshot of the OS partition (called it bad), restored a snapshot from February - still two AWOL file systems(?) Installed all updates and the file systems came back(??) So another snapshot to save where I had progressed to and restored the bad snapshot planning to reinstall the latest kernel and see what would happen. Booted the restored bad snapshot - before doing anything else - the file systems were back(???) Now that I am back in operation I ran some cp commands with the -P and --parents options. It seems that -P does not do the same as --parents on Ubuntu - same as your OpenSuse box. Thanks again, Ken |
All times are GMT -5. The time now is 06:31 PM. |