0

I know that I can simply substitute a string with another in the previous command by typing:

!!:gs/string1/string2/

But how I can perform multiple substitutions, e.g. having a command:

echo "AAAAAAAAAAAAAAAAA" > test1

I want to substitute A with B and 1 with 2, so execute such a command:

echo "BBBBBBBBBBBBBBBBB" > test2

How can I do it with !! operator?

3
$ echo "AAAAAAAAAAAAAAAAA" > test1
$ !!:gs/A/B/:s/1/2/
echo "BBBBBBBBBBBBBBBBB" > test2

That is, just add the second substitution to the end of the first. Just be aware that the second substitution will act on the result of the first.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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