Multiple substitution when repeating the previous command
Clash Royale CLAN TAG#URR8PPP
up vote
0
down vote
favorite
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?
bash command-line history-expansion
add a comment |Â
up vote
0
down vote
favorite
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?
bash command-line history-expansion
add a comment |Â
up vote
0
down vote
favorite
up vote
0
down vote
favorite
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?
bash command-line history-expansion
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?
bash command-line history-expansion
edited Jul 11 at 7:39
Kusalananda
101k13199312
101k13199312
asked Jul 11 at 7:30
K. Koovalsky
103
103
add a comment |Â
add a comment |Â
1 Answer
1
active
oldest
votes
up vote
3
down vote
accepted
$ 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.
add a comment |Â
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
3
down vote
accepted
$ 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.
add a comment |Â
up vote
3
down vote
accepted
$ 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.
add a comment |Â
up vote
3
down vote
accepted
up vote
3
down vote
accepted
$ 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.
$ 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.
edited Jul 11 at 7:44
answered Jul 11 at 7:36
Kusalananda
101k13199312
101k13199312
add a comment |Â
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f454628%2fmultiple-substitution-when-repeating-the-previous-command%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password