Embrace `!!` and `^` for Effortless Command Recall

Quick Tip

Embrace `!!` and `^` for Effortless Command Recall

Challenge: You’ve just run a complex command and realized you made a small typo or need to modify it slightly. Re-typing the entire thing is tedious and error-prone.

The Solution: Bash provides built-in shortcuts to recall and edit previous commands.

!! ^old^new

Why it works: `!!` expands to the last command you entered, allowing you to re-run it instantly. The `^old^new` syntax, when used as the *first* part of the command (preceded by an implicit `!!`), replaces the first occurrence of “old” in the previous command with “new” before executing it.

Pro-Tip: Use `^old^new` followed by Enter to preview the modified command without executing it, then press the Up arrow and Enter to run the corrected version.

Linux Tips & Tricks | © ngelinux.com | 4/27/2026

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Newest
Oldest Most Voted
Inline Feedbacks
View all comments