Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. 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, if I run this command:

echo aaaaaaa

I get aaaaaaa (duh)

But then if I type in


I end up with baaaaaa

What would I type to end up with bbbbbbb ?

share|improve this question
While it doesn't save keystrokes except in very rare complex cases, you also have the option of fc to edit commands in your preferred editor. – jw013 Nov 30 '11 at 3:13
up vote 7 down vote accepted

In bash, I don't think you can combine the ^ shortcut with any modifier. That leaves the long form:


In zsh, the G modifier is a special case, you can use it with ^:

share|improve this answer

^search^replacement is syntactic sugar for !:s/search/replacement/, which is explained in this answer. The version that replaces all instances is !:gs/search/replacement/; I think that's the shortest form there is

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.