Take the 2-minute tour ×
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.

In bash, if I run this command:

echo aaaaaaa

I get aaaaaaa (duh)

But then if I type in

^a^b

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
add comment

2 Answers

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:

!!:gs/a/b/

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

^a^b^:G
share|improve this answer
add comment

^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
add comment

Your Answer

 
discard

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.