2

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?

Gilles 'SO- stop being evil'
  • 807,993
  • 194
  • 1,674
  • 2,175
moleculea
  • 37
  • 3

1 Answers1

3

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

!!:gs/5742/2839/
fedorqui
  • 7,603
  • 7
  • 35
  • 71