csot/contest

Task 01 — Find large files

Write a script 01.sh that takes a directory and prints all regular files strictly larger than 1 MiB (> 1048576 bytes), sorted by size descending.

Submit as

01.sh

Input

Source Format
CLI ./01.sh <dir> — one argument: path to a directory to scan
Filesystem All regular files under <dir> (recursive). Symlinks and directories are ignored.

Output

Stream Format
stdout One line per matching file: <size_in_bytes><TAB><path>
<size_in_bytes> — integer byte count (no units suffix)
<path> — path relative to <dir> (not absolute)
Lines sorted by size descending (largest first)
Files with size ≤ 1 048 576 bytes must not appear
stderr Not checked (keep empty if possible)
Exit code 0 on success

Example

Given this tree under input/:

input/
├── small.log         (500 KiB)
├── dir1/
│   ├── medium.bin    (1 MiB exactly — excluded)
│   └── big.tar       (3 MiB)
└── dir2/
    └── huge.iso      (10 MiB)
./01.sh input

Expected stdout:

10485760    dir2/huge.iso
3145728 dir1/big.tar

What the grader checks

Visible (4 pts) — public fixture tree. On listing mismatch: expected lines vs got.

  • Exit code 0 (1 pt)
  • Full stdout listing for the public tree (3 pt)

Hidden (3 pts) — pass/fail only: no exactly-1 MiB files listed; exactly three output lines.

Hints

  • find -size +1M — strictly greater than 1 MiB
  • find -printf '%s\t%P\n' — bytes, tab, path relative to search root
  • sort -rn — numeric descending

Points: 7 (partial grading)

Other tasks