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

This question already has an answer here:

I know I can replace a string of the previous command using ^old^new. But it seems to only replace the first occurrences as I do the follow:

$ cat /proc/5742/task/5742/status
$ ^5742^2839
cat /proc/2839/task/5742/status
cat: /proc/2839/task/5742/status: No such file or director

How to replace all occurrences, if possible?

share|improve this question

marked as duplicate by jasonwryan, Graeme, slm, vonbrand, casey Mar 18 '14 at 3:07

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.

up vote 2 down vote accepted

As ^old^new corresponds to !!:s/old/new, you can use the following to make a global replacement:

share|improve this answer

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