Bash: Replace all occurrences of a word in the last command
Fresh3 days ago
Mar 15, 20265068 viewsConfidence Score0%
0%
Problem
Almost by mistake, I figured out you could do something like: And that runs the same command with instead of . Now, how about if I have multiple occurrences of the target word? For example: It only replaces the first extension. How do I get it to replace both?
Error Output
$ cp foo.data bar1.data $ ^bar1^bar2
Unverified for your environment
Select your OS to check compatibility.
1 Fix
Canonical Fix
Unverified Fix
New Fix – Awaiting Verification
Fix for: Bash: Replace all occurrences of a word in the last command
Low Risk
I think is equivalent to , so it will only substitute the first word. If you want the whole line substituted, I think you'll have to use
Awaiting Verification
Be the first to verify this fix
Sign in to verify this fix