Copy Directories


cp -R

So far you've looked at copying files, but there are times you'll want to copy directories as well. You can't just enter cp source-directory target-directory, though, because that won't work as you expected; the directory will copy, but not the files inside it.

$ pwd /home/scott $ cp libby libby_bak cp: omitting directory  'libby' 


If you want to copy directories, you need to include the -R option (or --recursive), which you should recall from the ls command. The addition of -R means that the directory, as well as its contents, are copied.

$ pwd /home/scott $ ls -l drwxr-xr-x   328 2005-10-17 14:42 documents drwxr-xr-x   240 2005-10-20 17:16 libby $ cp -R libby libby_bak $ ls -l drwxr-xr-x   328 2005-10-17 14:42 documents drwxr-xr-x   240 2005-10-20 17:16 libby drwxr-xr-x   240 2005-10-20 17:17 libby_bak 




Linux Phrasebook
Linux Phrasebook
ISBN: 0672328380
EAN: 2147483647
Year: 2007
Pages: 288

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net