Use small tools for calculations and reports
By the end: Format dates, calculate values, sample records, and recognize commands that send or repeat output.
The idea
Small tools compose well when their outputs and limits are explicit. Timezones affect reports and schedules. Integer division differs from decimal arithmetic. A generated stream can be infinite, and a system-wide message reaches real people; neither belongs in an unattended experiment without a limit or purpose.
Your command toolkit
cal
What it solves: Read a calendar in the terminal.
cal
Normally shows the current month. Options differ between util-linux and other implementations; check local help before using a date in automation.
bc
What it solves: Calculate with decimal precision.
printf 'scale=2; 7/2\n' | bc
Prints 3.50. scale controls fractional precision for division; default integer-like results can otherwise surprise you.
factor
What it solves: Break an integer into prime factors.
factor 84
Prints 2, 2, 3, and 7 as factors. It is a small example of passing data through a focused utility.
date
What it solves: Use an unambiguous report timestamp.
date -u '+%Y-%m-%dT%H:%M:%SZ'
Prints UTC with an explicit Z suffix. Reading time is different from setting the host clock.
expr
What it solves: Evaluate a simple integer expression.
expr 7 + 2
Arguments need spaces. Shell arithmetic such as $((7 + 2)) is often clearer in Bash; expr remains useful to recognize in older scripts.
shuf
What it solves: Take a random sample of records.
printf 'files\nnetwork\nprocesses\n' | shuf -n 1
Selects one input line. Random sampling here is for practice, not security-sensitive random values.
yes
What it solves: Generate a repeated stream with a bound.
yes practice | head -n 3
head limits the visible output to three lines. The upstream process may receive SIGPIPE when the pipe closes; never use yes to blindly approve unknown prompts.
wall
What it solves: Understand messages to logged-in terminals.
wall --help
Actual wall messages can interrupt other users. Read the help here; coordinate a real maintenance notice through your team's agreed process.
Before you move on
Try the guided lab below. Compare the result with the explanation, then record your reasoning in the workbook. A missing optional program or a restricted environment is something to explain, not a reason to change system settings blindly.
Practice with evidence
- Predict the result
- Run the guided lab
- Compare the output
- Explain your choice
A worked example
Guided lab
date -u '+%Y-%m-%dT%H:%M:%SZ'
printf 'scale=2; 7/2\n' | bc
expr 7 + 2
printf 'files\nnetwork\nprocesses\n' | shuf -n 1
What to expect: A UTC timestamp, 3.50 from bc if installed, 9 from expr, and one randomly selected topic.
Make it yours: Write a tiny report with a timestamp and a calculation. Explain its timezone and why your chosen arithmetic tool gives the expected precision.
Read further
- GNU Coreutils manual ↗www.gnu.org
Apply what you learned
Your private practice
Answers are private. Completion requires the correct knowledge-check answer and a written response when an activity is included.
Restore a downloaded workbook
Choose a recovery file for this course and version. Review the recovered copy before saving it to your account.
Ask a question or report a problem
Describe what needs attention. Your private answer is shared only if you select the option below.