Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

This question already has an answer here:

New to linux :-)

In my .bashrc I have set -o vi.
That way when I'm in the terminal I can press CTRL +{ and then use VI commands to navigate, edit and search the command history.

One thing I cannot figure out is how to find and replace. Let's say for example, I have the following command cp /abc/*.src /def/*.src. How can I find/replace src with trg?

To clarify, I'm NOT in the VI/VIM editor. I'm on the command-line. For example, on the command-line to access the last command, i can do the following:

CTRL +{ k

Then to append to the end of command I can do:

$ a

How can I change my command using find/replace on the command-line.

Thanks

share|improve this question

marked as duplicate by Radu Rădeanu, Seth, Eric Carvalho, Mitch, Tom Brossman Jul 26 '13 at 15:59

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

    
So what for all discussion about vi (in title, tags, ...) as time as you want find/replace on the history command-line? –  Radu Rădeanu Jul 25 '13 at 18:08

1 Answer 1

The command for replacing a string with another in vi editor is

  %s/FindMe/ReplaceME/g

for more information on usage : vim

share|improve this answer
    
pls see my edits...thanks –  hba Jul 25 '13 at 17:50

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