Course / The terminal and the language
Filter out noise and search whole trees
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/02-03-grep-invert-recursive-extended
cd 02-03-grep-invert-recursive-extended
gonomicon submitGoal
The folder testdata/logs holds several log files in nested folders. Print every line that contains error or warn, except lines that also contain debug, sorted alphabetically.
Example
If testdata/logs/a.log held:
info fine
warn disk
debug warn ignored
your script prints (note the file name grep -r adds in front):
testdata/logs/a.log:warn disk
Rules
- Edit
answer.sh. Search the wholetestdata/logsfolder, including every sub-folder. - Keep the file-name prefix that
grep -rprints. Do not remove it. - End your pipeline with
sortso the lines come out in a fixed order. - Matching is case-sensitive: the words are lower-case in these logs.
What you'll practice
grep -r, grep -E, grep -v, pipes, and sort.
Run it
gonomicon fetch week-1/02-03-grep-invert-recursive-extended
cd 02-03-grep-invert-recursive-extended
gonomicon test
gonomicon submit
Hints
grep -rsearches every file inside a folder.-Elets you writeerror|warn.- Chain two greps with a pipe: the first finds, the second removes lines with
grep -v. - Finish with
| sortso the output order never changes.