linux numfmt 命令--转换数字

numfmt


SYNOPSIS

       numfmt [OPTION]... [NUMBER]...


DESCRIPTION

       Reformat  NUMBER(s),  or  the  numbers  from standard input if none are
       specified.

       Mandatory arguments to long options are  mandatory  for  short  options
       too.

       --debug
              print warnings about invalid input

       -d, --delimiter=X
              use X instead of whitespace for field delimiter

       --field=N
              replace the number in input field N (default is 1)

       --format=FORMAT
              use  printf  style  floating-point  FORMAT; see FORMAT below for
              details

       --from=UNIT
              auto-scale input numbers to UNITs; default is 'none';  see  UNIT
              below

       --from-unit=N
              specify the input unit size (instead of the default 1)

       --grouping
              use  locale-defined  grouping  of  digits, e.g. 1,000,000 (which
              means it has no effect in the C/POSIX locale)

       --header[=N]
              print (without converting) the first N header lines; N  defaults
              to 1 if not specified

       --invalid=MODE
              failure  mode for invalid numbers: MODE can be: abort (default),
              fail, warn, ignore

       --padding=N
              pad the output to N characters;  positive  N  will  right-align;
              negative  N will left-align; padding is ignored if the output is
              wider than N; the default is to automatically pad if  a  whites-
              pace is found

       --round=METHOD
              use  METHOD  for rounding when scaling; METHOD can be: up, down,
              from-zero (default), towards-zero, nearest


   UNIT options:
       none   no auto-scaling is done; suffixes will trigger an error

       auto   accept optional single/two letter suffix:

              1K = 1000, 1Ki = 1024, 1M = 1000000, 1Mi = 1048576,

       si     accept optional single letter suffix:

              1K = 1000, 1M = 1000000, ...

       iec    accept optional single letter suffix:

              1K = 1024, 1M = 1048576, ...

       iec-i  accept optional two-letter suffix:

              1Ki = 1024, 1Mi = 1048576, ...

       FORMAT  must be suitable for printing one floating-point argument '%f'.
       Optional quote (%'f) will enable --grouping (if  supported  by  current
       locale).   Optional  width value (%10f) will pad output. Optional nega-
       tive width values (%-10f) will left-pad output.

       Exit status is 0 if all input numbers were successfully converted.   By
       default,  numfmt will stop at the first conversion error with exit sta-
       tus 2.  With --invalid='fail' a warning is printed for each  conversion
       error  and the exit status is 2.  With --invalid='warn' each conversion
       error is diagnosed, but the exit status is 0.  With  --invalid='ignore'
       conversion errors are not diagnosed and the exit status is 0.


EXAMPLES

              $ numfmt --to=si 1000

              -> "1.0K"

              $ numfmt --to=iec 2048

              -> "2.0K"

              $ numfmt --to=iec-i 4096

              -> "4.0Ki"

              $ echo 1K | numfmt --from=si

              -> "1000"

              $ echo 1K | numfmt --from=iec

              -> "1024"

       GPL version 3 or later <http://gnu.org/licenses/gpl.html>.
       This is free software: you are free  to  change  and  redistribute  it.
       There is NO WARRANTY, to the extent permitted by law.
posted @   鸭子船长  阅读(1325)  评论(0编辑  收藏  举报
编辑推荐:
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
· 没有源码,如何修改代码逻辑?
阅读排行:
· 全程不用写代码,我用AI程序员写了一个飞机大战
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 记一次.NET内存居高不下排查解决与启示
· DeepSeek 开源周回顾「GitHub 热点速览」
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
点击右上角即可分享
微信分享提示