Vihaan Verma
Vihaan Verma

Reputation: 13143

Bash: more than one command line substitution

$touch file{1,2}
$echo "file1" >>  file1
$^1^2
=>echo "file2">>file1

But I wanted it to be

echo "file2">>file2

How to do more than one substitution ?

Upvotes: 2

Views: 75

Answers (1)

William Pursell
William Pursell

Reputation: 212464

!!:gs/1/2

should do it. ^1^2 is a shortcut for !!:s/1/2, and you just need to supply the g flag.

Upvotes: 2

Related Questions