Bash history: real life example for & modifiers

258 views Asked by At

I am looking learning new tricks in bash command history manipulation, in this page http://www.gnu.org/software/bash/manual/html_node/Modifiers.html#Modifiers. I see & modifiers.

when I try !!:& is not recalling previous substitution. Can you help to understand this with real example?

1

There are 1 answers

0
Miserable Variable On BEST ANSWER

First command:

$ echo abcdabcd
abcdabcd

Replace cd with gf. Note that only the first occurrence is replaced

$ !!:s/cd/gf
echo abgfabcd
abgfabcd

Repeat the substitution

$ !!:&
echo abgfabgf
abgfabgf