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.

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 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.

1 Answer 1

up vote 2 down vote accepted

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

!!:gs/5742/2839/
share|improve this answer

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