Course / The terminal and the language
Pull a column and change its case
How to fetch and submit this lab
Once: install the tool and connect your account.
curl -fsSL https://gonomicon.com/install.sh | sh
gonomicon loginEach lab: download it, edit the file named in the instructions, then submit.
gonomicon fetch week-1/03-02-cut-and-tr-column-case
cd 03-02-cut-and-tr-column-case
gonomicon submitGoal
The file testdata/people.csv is comma-separated. Print the first field of every line, uppercased, one per line.
Example
If testdata/people.csv held:
dana,28,seattle
erin,33,boston
your script prints:
DANA
ERIN
One line of output per line of input, in the same order. If a line's first field is empty, print an empty line.
Rules
- Edit
answer.sh. Readtestdata/people.csv; do not hard-code the names. - The separator is a comma. Field 1 is the first field, counting from 1. Every line has at least one comma.
- Uppercase the output, whatever case the names are in.
- Print no header and no extra lines.
What you'll practice
cut -d ... -f 1, tr 'a-z' 'A-Z', and piping one command into another.
Run it
gonomicon fetch week-1/03-02-cut-and-tr-column-case
cd 03-02-cut-and-tr-column-case
gonomicon test
gonomicon submit
Hints
cut -d "," -f 1keeps the first comma-separated field of every line.tr 'a-z' 'A-Z'turns each lowercase letter into uppercase.- Pipe the two together:
cut -d "," -f 1 testdata/people.csv | tr 'a-z' 'A-Z'.