-6

I read that they stand for recursively in the man page. However, I am not sure what their role is in the command. When I tried to copy some empty directory into another directory with,

$ cp EMPDIR DESTDIR

it does not work, with error massage cp: -r not specified; omitting directory 'empdir'

but when I executed

$ cp -r or -R EMPDIR DESTDIR

It works.

What is the exact function of -r and -R? Thank you for reading :)

  • 2
    If you know how to read the manpage of find, what have you read about in man page of cp? – 炸鱼薯条德里克 May 7 at 1:42
  • oh it was my mistake, I read it from manpage of cp – Godpoong May 7 at 1:45
  • 2
    Is you question, “what does recursive mean?” — You can edit the question. – ctrl-alt-delor May 7 at 6:20
0

The -r or -R switch tells the cp command to copy the directory recursively which includes all files and subdirectories. It is necessary for copying directories but not files.

You are getting the error in your question when you don't use it because you are trying to copy a directory without using -r or -R.

The same can be done with cp --recursive. This is all covered in the man page.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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