www.delorie.com/gnu/docs/textutils/coreutils_4.html   search  
Buy GNU books!

GNU Core-utils

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

2.2 Block size

Some GNU programs (at least df, du, and ls) display file sizes in "blocks". You can adjust the block size to make file sizes easier to read. The block size used for display is independent of any filesystem block size.

Normally, disk usage sizes are rounded up, disk free space sizes are rounded down, and other sizes are rounded to the nearest value with ties rounding to an even value.

The default block size is chosen by examining the following environment variables in turn; the first one that is set determines the block size.

This specifies the default block size for the df command. Similarly, DU_BLOCK_SIZE specifies the default for du and LS_BLOCK_SIZE for ls.

This specifies the default block size for all three commands, if the above command-specific environment variables are not set.

If neither the command_BLOCK_SIZE nor the BLOCK_SIZE variables are set, but this variable is set, the block size defaults to 512.

If none of the above environment variables are set, the block size currently defaults to 1024 bytes, but this number may change in the future.

A block size specification can be a positive integer specifying the number of bytes per block, or it can be human-readable or si to select a human-readable format. Integers may be followed by suffixes that are upward compatible with the SI prefixes for decimal multiples and with the IEC 60027-2 prefixes for binary multiples.

With human-readable formats, output sizes are followed by a size letter such as `M' for megabytes. BLOCK_SIZE=human-readable uses powers of 1024; `M' stands for 1,048,576 bytes. BLOCK_SIZE=si is similar, but uses powers of 1000 and appends `B'; `MB' stands for 1,000,000 bytes.

An integer block size can be followed by a suffix to specify a multiple of that size; in this case an omitted integer is understood to be 1. A bare size letter, or one followed by `iB', specifies a multiple using powers of 1024. A size letter followed by `B' specifies powers of 1000 instead. For example, `M' and `MiB' are equivalent to `1048576', whereas `MB' is equivalent to `1000000'.

The following suffixes are defined. Large sizes like 1Y may be rejected by your computer due to limitations of its arithmetic.

kilobyte: 10^3 = 1000.
kibibyte: 2^10 = 1024. `K' is special: the SI prefix is `k' and the IEC 60027-2 prefix is `Ki', but tradition and POSIX use `k' to mean `KiB'.
megabyte: 10^6 = 1,000,000.
mebibyte: 2^20 = 1,048,576.
gigabyte: 10^9 = 1,000,000,000.
gibibyte: 2^30 = 1,073,741,824.
terabyte: 10^12 = 1,000,000,000,000.
tebibyte: 2^40 = 1,099,511,627,776.
petabyte: 10^15 = 1,000,000,000,000,000.
pebibyte: 2^50 = 1,125,899,906,842,624.
exabyte: 10^18 = 1,000,000,000,000,000,000.
exbibyte: 2^60 = 1,152,921,504,606,846,976.
zettabyte: 10^21 = 1,000,000,000,000,000,000,000
2^70 = 1,180,591,620,717,411,303,424. (`Zi' is a GNU extension to IEC 60027-2.)
yottabyte: 10^24 = 1,000,000,000,000,000,000,000,000.
2^80 = 1,208,925,819,614,629,174,706,176. (`Yi' is a GNU extension to IEC 60027-2.)

Block size defaults can be overridden by an explicit `--block-size=size' option. The `-k' option is equivalent to `--block-size=1K', which is the default unless the POSIXLY_CORRECT environment variable is set. The `-h' or `--human-readable' option is equivalent to `--block-size=human-readable'. The `--si' option is equivalent to `--block-size=si'.

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

  webmaster     delorie software   privacy  
  Copyright 2003   by The Free Software Foundation     Updated Jun 2003