21.12 Copying Files to a DirectorySeveral commands like cp and mv will let you copy a file to a directory. That is, given the command: % if somewhere is a directory, cp copies file1 into the directory, leaving its name unchanged. You get a new file whose relative pathname (1.21 ) is somewhere/file1 . A few commands, for example, mv and ln , have the same behavior. Of course, this version of the command looks the same as a "regular" cp command. This leads to a common frustration: what if the directory somewhere doesn't exist? Maybe you forgot to create it; maybe you misspelled the name. cp doesn't know that you really meant a directory, so it just copies file1 into a new file, somewhere , in the current directory. There are plenty of situations in which this can be plenty confusing, and even (if you're unlucky) lead to errors. There's an easy safeguard, though. If you're copying files into a
directory, add a slash and dot ( % This makes a pathname to the
special entry named % - |
|