{
    "mode": "info",
    "parameter": "numfmt",
    "section": "",
    "url": "https://www.chedong.com/phpMan.php/info/numfmt/json",
    "generated": "2026-07-28T19:19:47Z",
    "sections": {
        "File: coreutils.info,  Node: numfmt invocation,  Next: seq invocation,  Prev: factor invocation,  Up: Numeric operations": {
            "content": "",
            "subsections": [
                {
                    "name": "26.2 'numfmt': Reformat numbers",
                    "content": "'numfmt' reads numbers in various representations and reformats them as\nrequested.  The most common usage is converting numbers to/from human\nrepresentation (e.g.  '4G' ==> '4,000,000,000').\n\nnumfmt [OPTION]... [NUMBER]\n\n'numfmt' converts each NUMBER on the command-line according to the\nspecified options (see below).  If no NUMBERs are given, it reads\nnumbers from standard input.  'numfmt' can optionally extract numbers\nfrom specific columns, maintaining proper line padding and alignment.\n\nAn exit status of zero indicates success, and a nonzero value\nindicates failure.\n\nSee '--invalid' for additional information regarding exit status.\n\n\nThe program accepts the following options.  Also see *note Common\noptions::.\n\n'--debug'\nPrint (to standard error) warning messages about possible erroneous\nusage.\n\n'-d D'\n'--delimiter=D'\nUse the character D as input field separator (default: whitespace).\nNote: Using non-default delimiter turns off automatic padding.\n\n'--field=FIELDS'\nConvert the number in input field FIELDS (default: 1).  FIELDS\nsupports 'cut' style field ranges:\n\nN    N'th field, counted from 1\nN-   from N'th field, to end of line\nN-M  from N'th to M'th field (inclusive)\n-M   from first to M'th field (inclusive)\n-    all fields\n\n'--format=FORMAT'\nUse printf-style floating FORMAT string.  The FORMAT string must\ncontain one '%f' directive, optionally with ''', '-', '0', width or\nprecision modifiers.  The ''' modifier will enable '--grouping',\nthe '-' modifier will enable left-aligned '--padding' and the width\nmodifier will enable right-aligned '--padding'.  The '0' width\nmodifier (without the '-' modifier) will generate leading zeros on\nthe number, up to the specified width.  A precision specification\nlike '%.1f' will override the precision determined from the input\ndata or set due to '--to' option auto scaling.\n\n'--from=UNIT'\nAuto-scales input numbers according to UNIT.  See UNITS below.  The\ndefault is no scaling, meaning suffixes (e.g.  'M', 'G') will\ntrigger an error.\n\n'--from-unit=N'\nSpecify the input unit size (instead of the default 1).  Use this\noption when the input numbers represent other units (e.g.  if the\ninput number '10' represents 10 units of 512 bytes, use\n'--from-unit=512').  Suffixes are handled as with '--from=auto'.\n\n'--grouping'\nGroup digits in output numbers according to the current locale's\ngrouping rules (e.g Thousands Separator character, commonly '.'\n(dot) or ',' comma).  This option has no effect in 'POSIX/C'\nlocale.\n\n'--header[=N]'\nPrint the first N (default: 1) lines without any conversion.\n\n'--invalid=MODE'\nThe default action on input errors is to exit immediately with\nstatus code 2.  '--invalid='abort'' explicitly specifies this\ndefault mode.  With a MODE of 'fail', print a warning for each\nconversion error, and exit with status 2.  With a MODE of 'warn',\nexit with status 0, even in the presence of conversion errors, and\nwith a MODE of 'ignore' do not even print diagnostics.\n\n'--padding=N'\nPad the output numbers to N characters, by adding spaces.  If N is\na positive number, numbers will be right-aligned.  If N is a\nnegative number, numbers will be left-aligned.  By default, numbers\nare automatically aligned based on the input line's width (only\nwith the default delimiter).\n\n'--round=METHOD'\nWhen converting number representations, round the number according\nto METHOD, which can be 'up', 'down', 'from-zero' (the default),\n'towards-zero', 'nearest'.\n\n'--suffix=SUFFIX'\nAdd 'SUFFIX' to the output numbers, and accept optional 'SUFFIX' in\ninput numbers.\n\n'--to=UNIT'\nAuto-scales output numbers according to UNIT.  See Units below.\nThe default is no scaling, meaning all the digits of the number are\nprinted.\n\n'--to-unit=N'\nSpecify the output unit size (instead of the default 1).  Use this\noption when the output numbers represent other units (e.g.  to\nrepresent '4,000,000' bytes in blocks of 1KB, use '--to=si\n--to-unit=1000').  Suffixes are handled as with '--from=auto'.\n\n'-z'\n'--zero-terminated'\nDelimit items with a zero byte rather than a newline (ASCII LF).\nI.e., treat input as items separated by ASCII NUL and terminate\noutput items with ASCII NUL. This option can be useful in\nconjunction with 'perl -0' or 'find -print0' and 'xargs -0' which\ndo the same in order to reliably handle arbitrary file names (even\nthose containing blanks or other special characters).  Note with\n'-z' the newline character is treated as a field separator.\n\n\nThe following are the possible UNIT options with '--from=UNITS' and\n'--to=UNITS':\n"
                }
            ]
        },
        "NONE": {
            "content": "No scaling is performed.  For input numbers, no suffixes are\naccepted, and any trailing characters following the number will\ntrigger an error.  For output numbers, all digits of the numbers\nwill be printed.\n\nSI\nAuto-scale numbers according to the International System of Units\n(SI) standard.  For input numbers, accept one of the following\nsuffixes.  For output numbers, values larger than 1000 will be\nrounded, and printed with one of the following suffixes:\n\n'K'  =>  1000^1 = 10^3 (Kilo)\n'M'  =>  1000^2 = 10^6 (Mega)\n'G'  =>  1000^3 = 10^9 (Giga)\n'T'  =>  1000^4 = 10^{12} (Tera)\n'P'  =>  1000^5 = 10^{15} (Peta)\n'E'  =>  1000^6 = 10^{18} (Exa)\n'Z'  =>  1000^7 = 10^{21} (Zetta)\n'Y'  =>  1000^8 = 10^{24} (Yotta)\n",
            "subsections": []
        },
        "IEC": {
            "content": "Auto-scale numbers according to the International Electrotechnical\nCommission (IEC) standard.  For input numbers, accept one of the\nfollowing suffixes.  For output numbers, values larger than 1024\nwill be rounded, and printed with one of the following suffixes:\n\n'K'  =>  1024^1 = 2^{10} (Kibi)\n'M'  =>  1024^2 = 2^{20} (Mebi)\n'G'  =>  1024^3 = 2^{30} (Gibi)\n'T'  =>  1024^4 = 2^{40} (Tebi)\n'P'  =>  1024^5 = 2^{50} (Pebi)\n'E'  =>  1024^6 = 2^{60} (Exbi)\n'Z'  =>  1024^7 = 2^{70} (Zebi)\n'Y'  =>  1024^8 = 2^{80} (Yobi)\n\nThe 'iec' option uses a single letter suffix (e.g.  'G'), which is\nnot fully standard, as the iec standard recommends a two-letter\nsymbol (e.g 'Gi') - but in practice, this method common.  Compare\nwith the 'iec-i' option.\n",
            "subsections": []
        },
        "IEC-I": {
            "content": "Auto-scale numbers according to the International Electrotechnical\nCommission (IEC) standard.  For input numbers, accept one of the\nfollowing suffixes.  For output numbers, values larger than 1024\nwill be rounded, and printed with one of the following suffixes:\n\n'Ki'  =>  1024^1 = 2^{10} (Kibi)\n'Mi'  =>  1024^2 = 2^{20} (Mebi)\n'Gi'  =>  1024^3 = 2^{30} (Gibi)\n'Ti'  =>  1024^4 = 2^{40} (Tebi)\n'Pi'  =>  1024^5 = 2^{50} (Pebi)\n'Ei'  =>  1024^6 = 2^{60} (Exbi)\n'Zi'  =>  1024^7 = 2^{70} (Zebi)\n'Yi'  =>  1024^8 = 2^{80} (Yobi)\n\nThe 'iec-i' option uses a two-letter suffix symbol (e.g.  'Gi'), as\nthe iec standard recommends, but this is not always common in\npractice.  Compare with the 'iec' option.\n",
            "subsections": []
        },
        "AUTO": {
            "content": "'auto' can only be used with '--from'.  With this method, numbers\nwith 'K','M','G','T','P','E','Z','Y' suffixes are interpreted as\nSI values, and numbers with 'Ki',\n'Mi','Gi','Ti','Pi','Ei','Zi','Yi' suffixes are interpreted as\nIEC values.\n\n\nConverting a single number from/to human representation:\n$ numfmt --to=si 500000\n500K\n\n$ numfmt --to=iec 500000\n489K\n\n$ numfmt --to=iec-i 500000\n489Ki\n\n$ numfmt --from=si 1M\n1000000\n\n$ numfmt --from=iec 1M\n1048576\n\n# with '--from=auto', M=Mega, Mi=Mebi\n$ numfmt --from=auto 1M\n1000000\n$ numfmt --from=auto 1Mi\n1048576\n\nConverting from 'SI' to 'IEC' scales (e.g.  when a harddisk capacity\nis advertised as '1TB', while checking the drive's capacity gives lower\nvalues):\n\n$ numfmt --from=si --to=iec 1T\n932G\n\nConverting a single field from an input file / piped input (these\ncontrived examples are for demonstration purposes only, as both 'ls' and\n'df' support the '--human-readable' option to output sizes in\nhuman-readable format):\n\n# Third field (file size) will be shown in SI representation\n$ ls -log | numfmt --field 3 --header --to=si | head -n4\n-rw-r--r--  1     94K Aug 23  2011 ABOUT-NLS\n-rw-r--r--  1    3.7K Jan  7 16:15 AUTHORS\n-rw-r--r--  1     36K Jun  1  2011 COPYING\n-rw-r--r--  1       0 Jan  7 15:15 ChangeLog\n\n# Second field (size) will be shown in IEC representation\n$ df --block-size=1 | numfmt --field 2 --header --to=iec | head -n4\nFile system   1B-blocks        Used  Available Use% Mounted on\nrootfs             132G   104741408   26554036  80% /\ntmpfs              794M        7580     804960   1% /run/shm\n/dev/sdb1          694G   651424756   46074696  94% /home\n\nOutput can be tweaked using '--padding' or '--format':\n\n# Pad to 10 characters, right-aligned\n$ du -s * | numfmt --to=si --padding=10\n2.5K config.log\n108 config.status\n1.7K configure\n20 configure.ac\n\n# Pad to 10 characters, left-aligned\n$ du -s * | numfmt --to=si --padding=-10\n2.5K       config.log\n108        config.status\n1.7K       configure\n20         configure.ac\n\n# Pad to 10 characters, left-aligned, using 'format'\n$ du -s * | numfmt --to=si --format=\"%10f\"\n2.5K config.log\n108 config.status\n1.7K configure\n20 configure.ac\n\n# Pad to 10 characters, left-aligned, using 'format'\n$ du -s * | numfmt --to=si --padding=\"%-10f\"\n2.5K       config.log\n108        config.status\n1.7K       configure\n20         configure.ac\n\nWith locales that support grouping digits, using '--grouping' or\n'--format' enables grouping.  In 'POSIX' locale, grouping is silently\nignored:\n\n$ LCALL=C numfmt --from=iec --grouping 2G\n2147483648\n\n$ LCALL=enUS.utf8 numfmt --from=iec --grouping 2G\n2,147,483,648\n\n$ LCALL=taIN numfmt --from=iec --grouping 2G\n2,14,74,83,648\n\n$ LCALL=C ./src/numfmt --from=iec --format=\"==%'15f==\" 2G\n==     2147483648==\n\n$ LCALL=enUS.utf8 ./src/numfmt --from=iec --format=\"==%'15f==\" 2G\n==  2,147,483,648==\n\n$ LCALL=enUS.utf8 ./src/numfmt --from=iec --format=\"==%'-15f==\" 2G\n==2,147,483,648  ==\n\n$ LCALL=taIN ./src/numfmt --from=iec --format=\"==%'15f==\" 2G\n== 2,14,74,83,648==\n",
            "subsections": []
        }
    },
    "flags": [],
    "examples": [],
    "see_also": []
}