brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: ^old^new reruns the last shell command with one word changed

Shell
~/tips/tip-shell-caret-quick-substitution

systemctl status ngnix

Repeats the previous command after fixing one word with a quick substitution.

A typo in a long command is faster to fix with a substitution than with arrow keys.

$ systemctl status ngnix
$ ^ngnix^nginx

^old^new takes the previous command, replaces the first old with new, prints the result and runs it. It only replaces the first match. For all matches use !!:gs/old/new/. Add :p as in !!:p to print an expanded history line without running it. Works in bash and zsh when history expansion is on, which it is by default in interactive shells.

Further reading: Bash manual: History Expansion

More Shell tips zmv -n '(*).log' '$1.txt' zoxide query -ls project f=$(mktemp --suffix=.json) shopt globskipdots echo $EPOCHSECONDS All Shell tips (78) All topics

Link