Linux Survival Basics
Read-only, can be slowCount Failures by Test File
A CI log has repeated failures and you need to see which files appear most often.
Command
grep -RhoE '[A-Za-z0-9_./-]+\.(test|spec)\.(js|ts|py|rb)' logs/ | sort | uniq -c | sort -nr | head
Before you run this
System impact: Read-only. Can create load on large logs, directories, filesystems, or process tables.
When not to use it: Do not use it when your CI emits structured JSON test reports that should be queried directly.
Expected output
A ranked list of test file paths with occurrence counts.
System impact
Read-only, can be slow. Nothing changes. The command extracts and counts file path mentions.
Scope this to the smallest useful path or service on busy systems.
Recovery / rollback: no state is changed.
When to use it
Use when a test suite produces many repeated failure lines.
When not to use it
Do not use it when your CI emits structured JSON test reports that should be queried directly.
Watch this command run
Command transcript
This sanitized transcript shows the commands and output shape without exposing host details.
$ cat logs/test.log
fail tests/checkout.spec.ts
fail tests/login.spec.ts
fail tests/checkout.spec.ts
$ grep -RhoE '[A-Za-z0-9_./-]+\.(test|spec)\.(js|ts|py|rb)' logs/ | sort | uniq -c | sort -nr | head
2 tests/checkout.spec.ts
1 tests/login.spec.ts
1 checkout.spec.ts
View commands shown
These are the commands shown in the sanitized transcript.
Commands shown
cat logs/test.loggrep -RhoE '[A-Za-z0-9_./-]+\.(test|spec)\.(js|ts|py|rb)' logs/ | sort | uniq -c | sort -nr | head
next steps
Related commands
Find the Largest CI Logs
Huge logs often point to loops, noisy tests, or runaway debug output.
find logs/ -type f -printf '%s %p\n' | sort -nr | head -10
Count Source Files by Extension
A quick extension count can show whether expected content made it into the source tree.
find source -type f -printf '%f\n' | sed -n 's/.*\.//p' | sort | uniq -c | sort -nr
Find the Files Eating Your Disk
The disk was full, but guessing at folders was the slow part.
find /var -type f -printf '%s %p\n' | sort -nr | head -20
Find the Largest Installed Packages
Disk cleanup starts with evidence, not random package removal.
dpkg-query -W -f='${Installed-Size}\t${Package}\n' | sort -nr | head -20
Show Big Files in Human Units
Byte counts are precise. Human units are faster under pressure.
find /var -type f -printf '%s %p\n' | sort -nr | head -10 | awk '{printf "%.1f MB %s\n", $1/1024/1024, $2}'
Study mapping
Use this as independent command practice: read the notes, predict the output, then compare it with the example before using a real shell.
Useful for
- LPIC-1 style command-line practice
- LFCS style performance tasks
- Linux+ style troubleshooting review
Independent study support only. No affiliation, endorsement, exam dumps, or real exam questions.