Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

8
  • What is counter intuitive about that? If shoot an arrow at a tree something happens, if I shoot the same arrow in the same direction but someone is standing in front of the tree something else happens. Same program different data, different outcome. Commented Dec 8, 2014 at 18:50
  • "I would have expected that cp -r dir1 dir2 (when dir2 already exists) would remove the existing dir2 (and any contents).." What? Why? I can understand overwritting files, but removing any pre-existing files as well? O.o Commented Dec 8, 2014 at 18:52
  • @anthon But I haven't provided different inputs. In your example, you're shooting an arrow in a constant direction, not at a tree. @muru I wouldn't expect cp file1 file2 to append if file2 exists, I expect it to overwrite. My basis for anticipated behavior is on a literal interpretation of the syntax and on what is done with files, though other users may expect differently. Commented Dec 8, 2014 at 19:29
  • 1
    @TTT The problem is directories and files are treated differently in enough commands (e.g., ls by default, rm, touch when given a non-existent directory as argument, etc.) that that argument doesn't hold water. Commented Dec 8, 2014 at 20:33
  • 1
    Similar question I asked a bit later but got more visibility: unix.stackexchange.com/q/228597 Commented Jan 16, 2023 at 19:54