GKRootWire
Security ICE Signs $2M Deal for Zero-Click Phone Hacking ToolSecurity Attackers Exploit Critical Elementor Pro Bug to Hijack WordPress SitesAI ChatGPT Goes Down, Serves 404 Errors to UsersAI ChatGPT and Codex Suffer Widespread OutageAI Google DeepMind's WeatherNext 3 Sharpens AI Weather ForecastingAI Google's New AI Weather Model Sharpens Storm ForecastsSecurity ICE Signs $2M Deal for Zero-Click Phone Hacking ToolSecurity Attackers Exploit Critical Elementor Pro Bug to Hijack WordPress SitesAI ChatGPT Goes Down, Serves 404 Errors to UsersAI ChatGPT and Codex Suffer Widespread OutageAI Google DeepMind's WeatherNext 3 Sharpens AI Weather ForecastingAI Google's New AI Weather Model Sharpens Storm Forecasts
Dev Tools

The Shell's '!' Isn't for Emphasis—It's a Shortcut You're Probably Underusing

A deep dive into bash and zsh's history expansion shows how the exclamation mark can save you from retyping long commands.

Most terminal users know '!!' repeats the last command, but a recent write-up argues that the exclamation mark's full history expansion powers go largely ignored. The shell's '!' operator isn't punctuation for shouting—it's a lazy shortcut for referencing previous commands without retyping them.

The article walks through lesser-known tricks: '!$' grabs the last argument of the previous command, '!^' grabs the first, '!*' grabs all arguments, and '!string' reruns the most recent command starting with that string. You can even combine these with substitution, like '!!:s/old/new/', to fix a typo in your last command without rewriting the whole line.

These features have existed in bash and zsh for decades, inherited from the original C shell, but they're easy to forget since most people rely on up-arrow and tab completion instead.

Why it matters: History expansion is one of those shell features that's invisible until you need it, and knowing it can shave real time off repetitive terminal work like rerunning a build with tweaked flags. It's also a good reminder that shells have deep, often underused feature sets worth revisiting periodically.

Sources: Hacker News