Text Processing (Grep/Sed/Awk)
Quit hunting for process paths in messy log files
đź§© The Challenge
You know the pain of staring at a multi-gigabyte application log where the file paths are scattered across different lines or buried in long JSON blobs. Trying to extract just the unique directories is a nightmare when you’re manually cleaning up output.
đź’ˇ The Fix
Use a quick awk workflow to isolate the fields containing your path data and trim the noise without writing a full script. It’s the fastest way to get a clean list of files the application touched.
grep -oE '/[a-zA-Z0-9._/-]+' application.log | awk -F/ '{$NF=""; print $0}' | sed 's/ /\//g' | sort -u
⚙️ Why It Works
Grep pulls out the strings that look like paths, then awk strips the trailing filename so you’re left with just the parent directory structure. Converting the spaces back into slashes via sed cleans up the mess awk makes when it parses those paths.
🚀 Pro-Tip: Pipe that into xargs ls -ld if you want to verify which of those directories actually exist on the disk right now.
Linux Tips & Tricks | © ngelinux.com | 9/12/2026
