Site icon New Generation Enterprise Linux

Stop grepping your history for commands you already forgot

Text Processing (Grep/Sed/Awk)

Stop grepping your history for commands you already forgot

🧩 The Challenge

We have all spent ten minutes hitting the up arrow looking for that one long, complicated find or ffmpeg command we ran last Tuesday. It is a massive waste of time and it makes me want to throw my monitor out the window.

💡 The Fix

Just pipe your shell history into awk to strip out the timestamps and deduplicate the lines. It turns a chaotic wall of text into a clean list of the commands you actually use.

history | awk '{$1=""; print $0}' | sort | uniq | grep "search_term"

⚙️ Why It Works

Because history output includes line numbers that change every time you run a command, piping into awk lets you target only the command string itself for sorting. This hides the noise so you can actually find what you need.

🚀 Pro-Tip: Alias this to histgrep and you will never spend more than three seconds finding a command again.

Linux Tips & Tricks | © ngelinux.com | 9/13/2026

0 0 votes
Article Rating
Exit mobile version