3 ms·
Try doing it with :#s///
by tus88 6y ago
Try doing it with :#s///
- samtheprogram 6y agoCould someone explain why this was downvoted? Is this dangerous, or does it not perform the same operation?
- mkl 6y agoIt is not dangerous, and does not perform the same operation (it is actually incorrect and incomplete: ":" and "#" swapped, and missing substitution words). I guess it was downvoted because it didn't explain? The bash manual does, though, under "HISTORY EXPANSION". Try this: Type a command, but don't press enter, e.g. echo 'hello'; Type !#:s/hello/world/ Press enter. !# means the whole current command so far, and the s/a/b/ modifier replaces the first instance of "a" with "b". Press up to get the command that ran: echo 'hello'; echo 'world'; To see such history expansion things before they are run, press M-^ (probably Alt-Shift-6).