cp Cannot Stat '-r'

9,189

Per the comments, it looks like you've copied a long-dash (–). This is syntactically different to a regular dash and the cp command is just reading it like it's a filename.

Endashes are slightly but noticeably longer than regular dashes. There's an even longer version called an emdash. Here's a comparison between the three:

- dash
– endash
— emdash

If you've copied this organically from a web page, this might explain it. Wordpress substitutes a double dash for an emdash and I'm sure there's a wierd substitution for an endash too.

To type this manually, most users need to use the compose key combo: Compose--.

If your keyboard is generating these on its own, there's something odd going on in your keymap. Longer dashes aren't —as far as I know— standard base punctuation for any language.

Share:
9,189

Related videos on Youtube

Dan Hanly
Author by

Dan Hanly

My name is Dan Hanly and I am a Full Stack Application Developer from Pontypridd in South Wales. I have a tremendous passion for developing in a range of languages and for bringing large-scale projects through their full development lifecycle into a production environment. I am highly capable and a quick learner, always bringing fresh ideas, out-of-the-box thinking and the ability to adapt my professional skills to any project requirement. I’m not constrained by technology, understanding instead the need to adopt the appropriate technology for each unique project. I am also keenly involved in the Open Source community, developing useful components and trying to involve myself in large projects in need of development help. My strengths are: Great at tackling complex problems I write clean, well-commented code Experienced with a range of testing (TDD & BDD) I follow development standards Experienced with task-automation Working in an Agile development environment Utilising git version control on all projects

Updated on September 18, 2022

Comments

  • Dan Hanly
    Dan Hanly over 1 year

    Strange issue, for some reason, when I'm running a copy command, it's treating the -r flag as an argument.

    sudo cp –r usr/* /usr
    

    The following is the error:

    cp: cannot stat ‘–r’: No such file or directory
    

    I know that -r doesn't exist as a file/directory, that's because it's a flag of to cp command, not an argument.

    How can I resolve this?

    • Dan Hanly
      Dan Hanly over 9 years
      So how to I ensure I'm always typing the correct one? My keyboard only has the one variation of it, and I'm sure I've never had this issue before.
  • Dan Hanly
    Dan Hanly over 9 years
    You are correct, I copied this from a web-page. And I retyped it myself and it was fine.