Course / The terminal and the language
Find big and recently changed files
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-06-find-by-size-and-age
cd 02-06-find-by-size-and-age
gonomicon submitGoal
The folder testdata holds files of different sizes that were changed at different times. Print two sorted lists of files: first the ones bigger than 1 kilobyte, then a separator line, then the ones changed within the last 2 days.
Example
If testdata held big.log (3 KB, changed last week) and new.txt (10 bytes, changed an hour ago), your script prints:
testdata/big.log
---
testdata/new.txt
Rules
- Edit
answer.sh. Search fromtestdataand list regular files only (-type f). - Each list is sorted with
| sort. The separator is a line containing only---(echo "---"). testdata/is created fresh each time you run the test, so the file times are always current. Run the test once to see the files, then look inside the folder.findrounds sizes up to the next whole unit, so a 1,025-byte file counts as 2k.
What you'll practice
find -size and find -mtime.
Run it
gonomicon fetch week-1/02-06-find-by-size-and-age
cd 02-06-find-by-size-and-age
gonomicon test
gonomicon submit
Hints
-size +1kmeans bigger than 1 kilobyte.-mtime -2means changed less than 2 days ago.- Add
-type fso only real files show up, not folders. - Print the separator with
echo "---"and sort each list.