DEV Community

Discussion on: Using grep and history command to find previous commands in Linux

Collapse
 
ferricoxide profile image
Thomas H Jones II

If you know the command you're trying to repeat, then !<starting-string> is great. Similarly, if you know the command you're trying to repeat, but you need to modify it, !<starting-string>:s/<SEARCH>/<REPLACE> or even !<starting-string>:gs/<SEARCH>/<REPLACE> are freaking awesome.

Note: This type of advanced command-history usage works in BASH and CSH-derived shells. Dunno about other shell-families.