Linux Fundamentals & Bash Scripting for Data Engineers
Use the shell confidently: paths, pipes, redirects, text tools, and scripts that glue pipeline steps together.
In plain words
pwd, ls, file, head, wc. Next, quote paths and pipe focused tools. Finally, log stdout/stderr, use exit codes, clean traps.
Think of it like…
The pipe is a conveyor belt: if one machine jams, pipefail stops the line instead of letting the final station report that it received zero parcels as success.
Where you’ve seen it
gzip -cd events.jsonl.gz | jq -c 'select(.status == "ok")' | awk -F, 'NF == 9' > valid.jsonl with tee for evidence and pipefail so a failed decompressor aborts the run.
Words you’ll hear
- Bash
- A shell command language that is useful for orchestration glue and text transformations, not usually for large in-process record logic.
- Pipes
- A
|stream that transfers stdout from one process into stdin of the next while processes run concurrently. - Text Tools
- Small Unix programs such as
awk,sed,sort,uniq,cut, andgrepthat compose around line-oriented data. - Operational boundary
- A command can print an error and still let the pipeline succeed because a shell reports the last command's status, while unquoted variables split whitespace and globs unpredictably. Use
#!/usr/bin/env bash,set -Eeuo pipefail, quote variables, check"$#"arguments, and send diagnostics to stderr while keeping machine-readable output on stdout.
Visual diagram
Theory & deep dive
Bash: the working mechanism
Bash connects pipeline executables through streams: standard input/output, pipelines, exit statuses, redirection, globbing, and text tools such as awk and sed.
pwd, ls, file, head, wc. Quote paths and pipe focused tools, then set -Eeuo pipefail and explicit checks; this exposes the state governed by Text Tools.
gzip -cd events.jsonl.gz | jq -c 'select(.status == "ok")' | awk -F, 'NF == 9' > valid.jsonl with tee for evidence and pipefail so a failed decompressor aborts the run.
Linux Fundamentals & Bash Scripting for Data Engineers: failure mode and production response
A command can print an error and still let the pipeline succeed because a shell reports the last command's status, while unquoted variables split whitespace and globs unpredictably.
Use #!/usr/bin/env bash, set -Eeuo pipefail, quote variables, check "$#" arguments, and send diagnostics to stderr while keeping machine-readable output on stdout. Track Pipeline status as "0 only when every required command succeeded", and make File descriptor 1 visible to the dataset owner.
#!/usr/bin/env bash, set -Eeuo pipefail, quote variables, check "$#" arguments, and send diagnostics to stderr while keeping machine-readable output on stdout.How it works, step by step
Step 1 of 41. Inspect
pwd, ls, file, head, wc. Bash connects pipeline executables through streams: standard input/output, pipelines, exit statuses, redirection, globbing, and text tools such as awk and sed.
- Pipeline status
- 0 only when every required command succeeded
- Pipes
- A `|` stream that transfers stdout from one process into stdin of the next while processes run concurrently.
When to use it & trade-offs
What it is
Bash connects pipeline executables through streams: standard input/output, pipelines, exit statuses, redirection, globbing, and text tools such as awk and sed. gzip -cd events.jsonl.gz | jq -c 'select(.status == "ok")' | awk -F, 'NF == 9' > valid.jsonl with tee for evidence and pipefail so a failed decompressor aborts the run.
Why it matters: A command can print an error and still let the pipeline succeed because a shell reports the last command's status, while unquoted variables split whitespace and globs unpredictably. Use #!/usr/bin/env bash, set -Eeuo pipefail, quote variables, check "$#" arguments, and send diagnostics to stderr while keeping machine-readable output on stdout.
When to reach for it
- Use the shell confidently: paths, pipes, redirects, text tools, and scripts that glue pipeline steps together.
- Choose Bash because it provides this capability: A shell command language that is useful for orchestration glue and text transformations, not usually for large in-process record logic.
- Keep evidence for Pipeline status at "0 only when every required command succeeded" so the last production stage-Operate - log stdout/stderr, use exit codes, clean traps-remains testable.
When to avoid or be careful
- A command can print an error and still let the pipeline succeed because a shell reports the last command's status, while unquoted variables split whitespace and globs unpredictably.
- Do not conflate Pipes with Bash. The second concept contributes different behavior: A
|stream that transfers stdout from one process into stdin of the next while processes run concurrently. - Release only after this guardrail is in place: Use
#!/usr/bin/env bash,set -Eeuo pipefail, quote variables, check"$#"arguments, and send diagnostics to stderr while keeping machine-readable output on stdout.
Bash / Pipes / Text Tools - roles, limits, and operating cost
Strengths: A shell command language that is useful for orchestration glue and text transformations, not usually for large in-process record logic. Bash connects pipeline executables through streams: standard input/output, pipelines, exit statuses, redirection, globbing, and text tools such as awk and sed.
Watch out: A command can print an error and still let the pipeline succeed because a shell reports the last command's status, while unquoted variables split whitespace and globs unpredictably.
| stream that transfers stdout from one process into stdin of the next while processes run concurrently.Strengths: A | stream that transfers stdout from one process into stdin of the next while processes run concurrently. In this workflow it supports: Guard - set -Eeuo pipefail and explicit checks.
Watch out: The operating cost is real: stdout; reserve it for real result data.
awk, sed, sort, uniq, cut, and grep that compose around line-oriented data.Strengths: Small Unix programs such as awk, sed, sort, uniq, cut, and grep that compose around line-oriented data. Its output can be checked with File descriptor 2.
Watch out: Operating guardrail: Use #!/usr/bin/env bash, set -Eeuo pipefail, quote variables, check "$#" arguments, and send diagnostics to stderr while keeping machine-readable output on stdout.
Interview signals & numbers to know
When this topic comes up
- “Where is the failure boundary for Bash, and how would Pipeline status reveal it?”
- “Why is Pipes distinct from this behavior: small Unix programs such as awk, sed, sort, uniq, cut, and grep that compose around line-oriented data?”
- Production clue: A command can print an error and still let the pipeline succeed because a shell reports the last command's status, while unquoted variables split whitespace and globs unpredictably.
- Design probe: Use #!/usr/bin/env bash, set -Eeuo pipefail, quote variables, check "$#" arguments, and send diagnostics to stderr while keeping machine-readable output on stdout.
Benchmarks & rules of thumb
- Pipeline status
- 0 only when every required command succeeded
- File descriptor 1
- stdout; reserve it for real result data
- File descriptor 2
- stderr; reserve it for diagnostics and failures
Common mistakes & follow-ups
Common interview mistakes
- A command can print an error and still let the pipeline succeed because a shell reports the last command's status, while unquoted variables split whitespace and globs unpredictably.
- Reporting success from a job exit code without checking Pipeline status and File descriptor 1.
- Treating this example as complete without replay, rollback, or access boundaries:
gzip -cd events.jsonl.gz | jq -c 'select(.status == "ok")' | awk -F, 'NF == 9' > valid.jsonlwithteefor evidence andpipefailso a failed decompressor aborts the run.
Likely interviewer follow-ups
- How would you prove this contract instead of only checking that the command ran: A shell command language that is useful for orchestration glue and text transformations, not usually for large in-process record logic.
- What does the recovery plan do when this occurs? A command can print an error and still let the pipeline succeed because a shell reports the last command's status, while unquoted variables split whitespace and globs unpredictably.
- When is Bash insufficient for File descriptor 1, and what does adding Pipes cost in Pipeline status?
#!/usr/bin/env bash, set -Eeuo pipefail, quote variables, check "$#" arguments, and send diagnostics to stderr while keeping machine-readable output on stdout.Knowledge check
Put it into practice
Practice related interview Q&A
Apply Linux Fundamentals & Bash Scripting for Data Engineers with data engineer interview Q&A and hands-on practice.