SI Learning
0% read · Practice is tracked separately
← My learning
Version 1 · Chapter 22Reading mode

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.

bash
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.

bash
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.

bash
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.

bash
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.

bash
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.

bash
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.

bash
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.

bash
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

  1. Predict the result
  2. Run the guided lab
  3. Compare the output
  4. Explain your choice

A worked example

Guided lab

bash
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

Apply what you learned

Your private practice

Why can 7/2 in bc produce 3 unless you set scale?

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.

All learning paths
SI CENTRALIZATION · LEARN

Linux Command Line: from first command to confident practice

24 chapters · Your own pace

0 of 24 chapters complete
Use small tools for calculations and reports | SI Centralization