5 ms·
Several distros unfortunately include 'mv' and 'cp' aliases by default. To get predictable behavior on the command line, always use '\mv' and '\cp'. (for bash
by downerending 7y ago
Several distros unfortunately include 'mv' and 'cp' aliases by default. To get predictable behavior on the command line, always use '\mv' and '\cp'. (for bash)
- JadeNB 7y agoI didn't know that! Why does it work?
- downerending 7y agoThe backslash basically means "ignore any aliases or functions by the same name, and run the first matching command in my $PATH instead". One reason for providing this is so that you can have an alias like alias mv '\mv -=myfavoritearg ' but it's also good for ensuring that you didn't pick up some distro nonsense.
- JadeNB 7y agoThanks! So '\' is special cased here—it's not some specific manifestation of a more general phenomenon of specialised escape-handling in the shell?
- downerending 7y agoIf I understand correctly, yes, that's how I'd describe it.
- a1369209993 7y ago> So '\' is special cased here No; quoting any part of the command name prevents alias expansion. Eg 'mv', "mv", 'm'v, m\v, etc all work.
- m463 7y agothat's a good tip. I've always used /bin/mv or /bin/ls to get just the command, but your method is shorter. (although I can't help but think of windows paths)