Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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

In Bash, Ctrl + W will erase the last word. Bash considers words to be delimited by spaces.

This means that if the cursor is at the end of the string "cd /dir1/dir2/dir3" and you hit Ctrl + W you will be left with "cd ".

Is there a Bash shortcut (custom defined is okay) that will leave me with "cd /dir1/dir2/"?

share|improve this question
possible duplicate:… .. also see questions listed at .. do any of those answer your question? – quack quixote Mar 29 '10 at 3:17
note with standard bash keys, you can do this with Meta+B then Ctrl+K (move-backward-word then cut-to-end-of-line); from… – quack quixote Mar 29 '10 at 3:40
up vote 3 down vote accepted

Try pressing Esc, then Ctrl-H (or Esc, then Backspace) which should be bound to backward-kill-word (and you could bind to something else).

share|improve this answer
Meta + Backspace does the same too. – hekevintran Mar 29 '10 at 8:29

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.