Pipeline Workflows
Filter Results with grep
locate returns everything matching the substring. Pipe to grep to narrow down:
# All config files, but only in /etc
locate ".conf" | grep "^/etc/"
# All Python files, but not in site-packages
locate ".py" | grep -v "site-packages"
Sorting Results
# Alphabetically
locate "nginx" | sort
# By directory grouping
locate "*.log" | sort -t/ -k3
Checking File Sizes After locate
locate has no size filtering. Follow up with ls or stat:
# Find large log files using locate + ls
locate -e "*.log" | xargs ls -lhS 2>/dev/null | head -20
Finding Duplicate Files by Name
# Find all files named exactly "config.yml" system-wide
locate -b "\config.yml" | sort
Auditing Config Files
# Find all nginx configs and check listen ports
locate -e "nginx.conf" | while IFS= read -r f; do
echo "=== $f ==="
grep "listen" "$f" 2>/dev/null
done
Quick Binary Locator
# Where is Python installed?
locate -b "\python3" | grep "/bin/"
# Where are all ffmpeg installations?
locate -b "\ffmpeg" | grep "/bin/"