coreutils: Block size

1 
1 2.3 Block size
1 ==============
1 
1 Some GNU programs (at least ‘df’, ‘du’, and ‘ls’) display sizes in
1 “blocks”.  You can adjust the block size and method of display to make
1 sizes easier to read.  The block size used for display is independent of
1 any file system block size.  Fractional block counts are rounded up to
1 the nearest integer.
1 
1    The default block size is chosen by examining the following
1 environment variables in turn; the first one that is set determines the
1 block size.
1 
1 ‘DF_BLOCK_SIZE’
1      This specifies the default block size for the ‘df’ command.
1      Similarly, ‘DU_BLOCK_SIZE’ specifies the default for ‘du’ and
1      ‘LS_BLOCK_SIZE’ for ‘ls’.
1 
1 ‘BLOCK_SIZE’
1      This specifies the default block size for all three commands, if
1      the above command-specific environment variables are not set.
1 
1 ‘BLOCKSIZE’
1      This specifies the default block size for all values that are
1      normally printed as blocks, if neither ‘BLOCK_SIZE’ nor the above
1      command-specific environment variables are set.  Unlike the other
1      environment variables, ‘BLOCKSIZE’ does not affect values that are
1      normally printed as byte counts, e.g., the file sizes contained in
1      ‘ls -l’ output.
1 
1 ‘POSIXLY_CORRECT’
1      If neither ‘COMMAND_BLOCK_SIZE’, nor ‘BLOCK_SIZE’, nor ‘BLOCKSIZE’
1      is set, but this variable is set, the block size defaults to 512.
1 
1    If none of the above environment variables are set, the block size
1 currently defaults to 1024 bytes in most contexts, but this number may
1 change in the future.  For ‘ls’ file sizes, the block size defaults to 1
1 byte.
1 
1    A block size specification can be a positive integer specifying the
1 number of bytes per block, or it can be ‘human-readable’ or ‘si’ to
1 select a human-readable format.  Integers may be followed by suffixes
1 that are upward compatible with the SI prefixes
1 (http://www.bipm.org/en/publications/si-brochure/chapter3.html) for
1 decimal multiples and with the ISO/IEC 80000-13 (formerly IEC 60027-2)
1 prefixes (https://physics.nist.gov/cuu/Units/binary.html) for binary
1 multiples.
1 
1    With human-readable formats, output sizes are followed by a size
1 letter such as ‘M’ for megabytes.  ‘BLOCK_SIZE=human-readable’ uses
1 powers of 1024; ‘M’ stands for 1,048,576 bytes.  ‘BLOCK_SIZE=si’ is
1 similar, but uses powers of 1000 and appends ‘B’; ‘MB’ stands for
1 1,000,000 bytes.
1 
1    A block size specification preceded by ‘'’ causes output sizes to be
1 displayed with thousands separators.  The ‘LC_NUMERIC’ locale specifies
1 the thousands separator and grouping.  For example, in an American
1 English locale, ‘--block-size="'1kB"’ would cause a size of 1234000
1 bytes to be displayed as ‘1,234’.  In the default C locale, there is no
1 thousands separator so a leading ‘'’ has no effect.
1 
1    An integer block size can be followed by a suffix to specify a
1 multiple of that size.  A bare size letter, or one followed by ‘iB’,
1 specifies a multiple using powers of 1024.  A size letter followed by
1 ‘B’ specifies powers of 1000 instead.  For example, ‘1M’ and ‘1MiB’ are
1 equivalent to ‘1048576’, whereas ‘1MB’ is equivalent to ‘1000000’.
1 
1    A plain suffix without a preceding integer acts as if ‘1’ were
1 prepended, except that it causes a size indication to be appended to the
1 output.  For example, ‘--block-size="kB"’ displays 3000 as ‘3kB’.
1 
1    The following suffixes are defined.  Large sizes like ‘1Y’ may be
1 rejected by your computer due to limitations of its arithmetic.
1 
1 ‘kB’
1      kilobyte: 10^3 = 1000.
1 ‘k’
1 ‘K’
1 ‘KiB’
1      kibibyte: 2^{10} = 1024.  ‘K’ is special: the SI prefix is ‘k’ and
1      the ISO/IEC 80000-13 prefix is ‘Ki’, but tradition and POSIX use
1      ‘k’ to mean ‘KiB’.
1 ‘MB’
1      megabyte: 10^6 = 1,000,000.
1 ‘M’
1 ‘MiB’
1      mebibyte: 2^{20} = 1,048,576.
1 ‘GB’
1      gigabyte: 10^9 = 1,000,000,000.
1 ‘G’
1 ‘GiB’
1      gibibyte: 2^{30} = 1,073,741,824.
1 ‘TB’
1      terabyte: 10^{12} = 1,000,000,000,000.
1 ‘T’
1 ‘TiB’
1      tebibyte: 2^{40} = 1,099,511,627,776.
1 ‘PB’
1      petabyte: 10^{15} = 1,000,000,000,000,000.
1 ‘P’
1 ‘PiB’
1      pebibyte: 2^{50} = 1,125,899,906,842,624.
1 ‘EB’
1      exabyte: 10^{18} = 1,000,000,000,000,000,000.
1 ‘E’
1 ‘EiB’
1      exbibyte: 2^{60} = 1,152,921,504,606,846,976.
1 ‘ZB’
1      zettabyte: 10^{21} = 1,000,000,000,000,000,000,000
1 ‘Z’
1 ‘ZiB’
1      2^{70} = 1,180,591,620,717,411,303,424.
1 ‘YB’
1      yottabyte: 10^{24} = 1,000,000,000,000,000,000,000,000.
1 ‘Y’
1 ‘YiB’
1      2^{80} = 1,208,925,819,614,629,174,706,176.
1 
1    Block size defaults can be overridden by an explicit
1 ‘--block-size=SIZE’ option.  The ‘-k’ option is equivalent to
1 ‘--block-size=1K’, which is the default unless the ‘POSIXLY_CORRECT’
1 environment variable is set.  The ‘-h’ or ‘--human-readable’ option is
1 equivalent to ‘--block-size=human-readable’.  The ‘--si’ option is
1 equivalent to ‘--block-size=si’.  Note for ‘ls’ the ‘-k’ option does not
1 control the display of the apparent file sizes, whereas the
1 ‘--block-size’ option does.
1