Linux issues with cp: -r not specified; omitting directory

9,682
cp: -r not specified; omitting directory '/home/administrator/Documents/myfile.10'

This means myfile.10 is a directory. cp won't copy it, unless you explicitly use -r (or equivalent) flag.

For cp in my Debian these are equivalent: -r, -R, --recursive. POSIX, however defines -R only (-r is mentioned as obsolescent). It says:

If source_file is of type directory, the following steps shall be taken:

  • If the -R option was not specified, cp shall write a diagnostic message to standard error, do nothing more with source_file, and go on to any remaining files.

[...]

The conclusion is your cp does exactly what it's supposed to do. If you want to copy the whole directory, use -R. If you expected myfile.10 to be a non-directory then you need to investigate why the discrepancy.

Share:
9,682

Related videos on Youtube

James Collis
Author by

James Collis

Updated on September 18, 2022

Comments

  • James Collis
    James Collis almost 2 years

    Can someone help me understand what that means?

    cp: -r not specified; omitting directory
    

    I am trying to use this command

    sudo cp /home/$USER/Documents/myfile.10 /home
    

    Error:

    cp: -r not specified; omitting directory '/home/administrator/Documents/myfile.10'
    

    What does it mean? Why did it happen? What can I do about it?

    • Kamil Maciorowski
      Kamil Maciorowski about 5 years
      Welcome to Super User. Please restrict to one question per question: either cp issue or the other. Asking for a test script without showing your research effort is not a good question; we are not a script writing service. If I were you I would get rid of this "Also ..." part (edit the question).
    • Kamil Maciorowski
      Kamil Maciorowski about 5 years
      I went ahead and edited the question to meet our standards. If you need help with LDAP (which is a separate issue) then please ask a new question. Your original question is archived here, in case you want to copy from it. You should take our tour and see How to Ask first. Good luck.