28 / 55 · 19 Linux & Command Line · Pipes and Redirection← prev⊞ allnext →☰ Read as one page
4.5Practical QA Pipe Chains
Analyzing Nginx Access Logs
# Top 10 most requested URLs
awk '{print $7}' /var/log/nginx/access.log | sort | uniq -c | sort -rn | head -10
# Top 10 IP addresses by request count
awk '{print $1}' /var/log/nginx/access.log | sort | uniq -c | sort -rn | head -10
# Count requests per HTTP status code
awk '{print $9}' /var/log/nginx/access.log | sort | uniq -c | sort -rn
# All 500 errors with timestamps
grep " 500 " /var/log/nginx/access.log | awk '{print $4, $7}' | tail -20
Analyzing Test Results
# Count passed/failed/skipped from JUnit XML
grep -c 'status="passed"' test-results/*.xml
grep -c 'status="failed"' test-results/*.xml
# Find all test files that contain .only (accidentally focused tests)
grep -rl "\.only" tests/ --include="*.spec.ts"
# List all test descriptions
grep -rh "test\('" tests/ --include="*.spec.ts" | sed "s/.*test('//" | sed "s/',.*//" | sort
Monitoring and Health Checks
# Check multiple endpoints and show status
for url in https://api.example.com/health https://web.example.com https://admin.example.com; do
STATUS=$(curl -s -o /dev/null -w "%{http_code}" --max-time 10 "$url")
echo "$url: $STATUS"
done
# Monitor a log file for errors and send an alert
tail -f /var/log/app/application.log | grep --line-buffered "CRITICAL" | while read line; do
echo "ALERT: $line" | mail -s "Critical Error" qa-team@example.com
done