Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bash nth command substitution?

Tags:

bash

I know that

$ ^previous^replacement^

will substitute "previous" with "replacement" in the last command in bash shell. How to substitute a nth command in the history?

like image 832
Ray Doyle Avatar asked Jul 23 '26 18:07

Ray Doyle


1 Answers

An example:

!n:s/previous/replacement/

See the HISTORY EXPANSION section of the man page for full details.

like image 73
martin clayton Avatar answered Jul 25 '26 17:07

martin clayton



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!