Hosting Operations
Read-only, can be slowShow Context Around the First Error
A log contains a clear error line, but the useful cause may be several lines above or below it.
Command
grep -RInC 3 -m 1 'ERROR' artifacts logs
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 stop at the first match if the job continued and later failed for another reason.
Expected output
A small context block around the first ERROR match.
System impact
Read-only, can be slow. Nothing changes. grep prints the first ERROR match with nearby lines.
Scope this to the smallest useful path or service on busy systems.
Recovery / rollback: no state is changed.
When to use it
Use after finding which logs contain error markers.
When not to use it
Do not stop at the first match if the job continued and later failed for another reason.
Watch this command run
Command transcript
This sanitized transcript shows the commands and output shape without exposing host details.
$ cd /work/ci-artifacts && grep -RIn 'ERROR' artifacts logs
artifacts/build/webpack.log:4:ERROR Module not found: Cannot resolve ./missing-module
artifacts/build/app-build.log:4:ERROR in src/server.ts:42: missing export createServer
artifacts/coverage/coverage-summary.txt:5:ERROR coverage below minimum threshold: statements 78.4 < 80.0
$ cd /work/ci-artifacts && grep -RInC 3 -m 1 'ERROR' artifacts logs
artifacts/build/webpack.log-1-webpack 5.91.0 compiled with 1 error
artifacts/build/webpack.log-2-asset main.js 245 KiB
artifacts/build/webpack.log-3-asset vendor.js 812 KiB
artifacts/build/webpack.log:4:ERROR Module not found: Cannot resolve ./missing-module
--
artifacts/build/app-build.log-1-Starting build
artifacts/build/app-build.log-2-Resolving dependencies
artifacts/build/app-build.log-3-Compiling app
artifacts/build/app-build.log:4:ERROR in src/server.ts:42: missing export createServer
artifacts/build/app-build.log-5-Build failed with exit code 1
--
artifacts/coverage/coverage-summary.txt-2-Statements: 78.4%
artifacts/coverage/coverage-summary.txt-3-Branches: 71.2%
artifacts/coverage/coverage-summary.txt-4-Functions: 81.0%
artifacts/coverage/coverage-summary.txt:5:ERROR coverage below minimum threshold: statements 78.4 < 80.0
$ cd /work/ci-artifacts && sed -n '1,12p' artifacts/build/app-build.log
Starting build
Resolving dependencies
Compiling app
ERROR in src/server.ts:42: missing export createServer
Build failed with exit code 1
View commands shown
These are the commands shown in the sanitized transcript.
Commands shown
cd /lab/ci-artifacts && grep -RIn 'ERROR' artifacts logscd /lab/ci-artifacts && grep -RInC 3 -m 1 'ERROR' artifacts logscd /lab/ci-artifacts && sed -n '1,12p' artifacts/build/app-build.log
next steps
Related commands
Scan Every CI Log for Error Lines
One grep pass can turn a log pile into a failure list.
grep -RInE 'error|failed|failure|exception|traceback' artifacts logs | head -50
Detect Secret Leak Markers in Artifacts
Artifacts are public more often than you think.
grep -RInE 'AWS_ACCESS_KEY|SECRET|TOKEN|PRIVATE KEY|PASSWORD' artifacts logs | head -50
Find Coverage Regression Lines
Coverage failures usually say the threshold out loud.
grep -RInE 'coverage|threshold|minimum|below' artifacts logs
Find Tests That Passed After Rerun
A green retry can still hide a flaky test.
grep -RInE 'rerun|retry|flaky|passed on retry|failed attempt' artifacts logs
Tail the Failing CI Lines
Skip the full CI log and jump straight to lines that usually explain the failure.
grep -RInE 'error|failed|exception|traceback|fatal' logs/ | tail -50
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.