Translating & Cutting Data
Concept & Overview
Imagine working with a CSV spreadsheet of transaction dates and names. You want to extract only the first column (dates) and convert all text to capital letters for consistency. In Linux, we can combine lightweight parsing tools in a pipeline:
- The cut command slices out specific columns from structured text. E.g., cut -d, -f1 splits lines by commas (-d,) and extracts the first column (-f1).
- The tr (translate) command transforms characters from standard input, like swapping lowercase characters for uppercase (tr "a-z" "A-Z").
Why this matters: If you run cut reports.csv without -d, and -f1, you will get: cut: you must specify a list of bytes, characters, or fields. If you specify -f1 but omit -d,, it defaults to tabs, meaning it won't split a CSV file and will just print the entire line. The -d, flag defines the comma as the column separator, and -f1 tells it to extract only the first column.
reports.csv using cut -d, -f1 reports.csv, pipe it into tr "a-z" "A-Z" to make it uppercase, and redirect the final result to upper_reports.txt.Command Syntax Reference
| Command / Syntax | Description |
|---|---|
cut -d, -f1 file | tr "a-z" "A-Z" | Pipe cut field into translation |
Verification Objectives
These conditions will be automatically verified when you run commands inside the interactive terminal simulator:
- ○Use "cut" with comma delimiter
- ○Translate characters to uppercase with "tr"
- ○Create file "upper_reports.txt"
- ○Verify text is UPPERCASE
Ready to complete Quest 110?
Test your skills live in the browser terminal with an emulated Linux filesystem, real-time command evaluation, and instant step-by-step hints.