A simple CLI tool to display the size of files and directories in bytes or human-readable format.
git clone https://github.com/S1THOF/Analize-path-size.git
cd Analize-path-size
make buildhexlet-path-size [FLAGS] PATHShow file size in bytes:
hexlet-path-size data.csv
# Output: 81B data.csvShow size in human-readable format:
hexlet-path-size --human data.csv
# Output: 81B data.csv
hexlet-path-size --human large-file.bin
# Output: 24.0MB large-file.binCalculate directory size recursively with hidden files:
hexlet-path-size -r -a --human /path/to/directory| Flag | Short | Description |
|---|---|---|
--human |
-H |
Display sizes in human-readable format (auto-selects appropriate unit: B, KB, MB, GB, etc.) |
--recursive |
-r |
Recursively calculate directory sizes (includes all subdirectories) |
--all |
-a |
Include hidden files and directories (those starting with a dot .) |
- Displays exact size in bytes followed by
B - Example:
12345B filename.txt
- Automatically selects the largest appropriate unit where the value is ≥ 1
- Units: B → KB → MB → GB → TB → PB → EB (base-2, 1 KB = 1024 bytes)
- Values < 1024 bytes: displayed as whole numbers (e.g.,
1000B) - Values ≥ 1024 bytes: displayed with one decimal place (e.g.,
1.2KB,24.0MB)
0: Success1: Error (file not found, permission denied, invalid arguments, etc.)
- Go 1.22 or higher
MIT