A shell utility to retrieve the disk space consumed by files within a directory
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
bin
CHANGELOG.md
LICENSE
README.md
install

README.md

bytes

Retrieves the amount of disk space consumed by files within a directory listing

bytes is a shell utility to calculate the disk space consumed by files within a directory.

Installation

The install script currently supports Linux as well as OSX. If you are on a different platform with access to sh or bash, simply add bytes to your path.

Execute the installation script via

./install

in order to add the bytes command to your PATH. You may need to restart your Terminal for changes to become effective.

Usage

To calculate the total number of bytes consumed by all visible (i.e. non-dot-) files within the current directory (non-recursive), simply enter

bytes

in your terminal.

You can also specify a different directory to calculate the file-size total for:

bytes <pathToDirectory>

If you are interested in a different unit (e.g. kilobytes or megabytes), use the -u option to specify the desired unit.

If you want to include hidden files, i.e. dot-files, in the total, use the -a option.

If you want to include subdirectories into the calculation, use the -r option.

Options

-a | --all

Include dot-files a.k.a. hidden files into the total.

-n | --newline

Do not print the trailing newline character.

-p | --precision <precision>

Specify the desired floating point precision for the output (default: 3).

-r | --recursive

If set, bytes recursively traverses subdirectories. (default: false)

-u | --unit <b | kb | mb | gb | tb>

Use this option to specify the desired unit for the disk space output. Supported units are:

  • b = bytes (default)
  • kb = kilobytes (1024 bytes)
  • mb = megabytes (1024 kilobytes)
  • gb = gigabytes (1024 megabytes)
  • tb = terabytes (1024 gigabytes)
-v | --version

Shows version information.

[No IEC support because we <3 binary and 1+1 still equals 10]

CHANGELOG

License

The MIT License (MIT)

Copyright (c) Hans-Peter Dietz | @h_p_d | h.p.dietz@gmail.com

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.