Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I just want to copy the contents of a directory and the subdirectories within it over to another directory in a Bash shell. I assumed cp -r would do this.

However, this isn't working:

cp -r $BASEDIR/Upload/Temp $BASEDIR/backup

The directory Temp has a bunch of files and directories in it. But after I run this command, I only get the files in backup. No directories are copied.

I'm also having the same problem with the -r option with a zip command. In the same Bash shell, I've got these commands:

cd $BASEDIR/Upload/Temp
zip -r $BASEDIR/Backup2/backup2.zip .

When I look at the contents of backup2.zip, all it has are the files, no subdirs. (I cd into the directory because it's the only way I know to store files in a zip without getting the absolute path stored as well, which I don't need.)

What am I not getting about the -r option?

share|improve this question
add comment

1 Answer 1

up vote 2 down vote accepted

Try:

  • cp -R maybe that will work, or
  • cp -rf, you can also try
  • cp -av origin_folder destiny_folder –
  • But cp -r /home/hope/files/* /home/hope/backup, should have worked.
share|improve this answer
    
cp -R worked. Strange that case made a difference, but... weirdness sometimes happens. –  Dave M G Mar 24 '12 at 12:31
    
the -r and -R are equivalent in the Ubuntu cp (coming from GNU coreutils), so probably you were making some other mistake. –  enzotib Mar 24 '12 at 17:05
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.