Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm on a Mac and the cp and mv commands are killing me due to them copying the contents of a directory if a trailing slash is present. It has bitten me more than once when I use tab completion to specify the directory I want to copy.

I have noticed zsh has a neat feature that removes the trailing slash if it's not needed after a space or enter key is pressed. Is there any way to have bash mimic this behavior?

share|improve this question
I removed the osx tag as it's probably not related to the problem. – phunehehe Nov 30 '11 at 5:37
Cross-posted on Super User. Please don't do that. – Gilles Nov 30 '11 at 23:08


set mark-directories off

in your ~/.inputrc, and ensure you have export INPUTRC=~/.inputrc in ~/.bashrc.

See also How to avoid cp -r ~/some/folder/ . copying all files to the current folder's top level?

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.