Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

numfmt

Some strings on this page have not been translated yet. You can help by translating them on Weblate.
v0.13.0
numfmt [OPCIÓN]... [NÚMERO]...

Convertir números desde/hacia cadenas legibles por humanos

Options

--debug

print warnings about invalid input

--grouping

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

--delimiter=<X>, -d <X>

use X instead of whitespace for field delimiter

--field=<FIELDS>

replace the numbers in these input fields; see FIELDS below

--format=<FORMAT>

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

--from=<UNIT>

auto-scale input numbers to UNITs; see UNIT below

--from-unit=<N>

specify the input unit size

--to=<UNIT>

auto-scale output numbers to UNITs; see UNIT below

--to-unit=<N>

the output unit size

--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 whitespace is found

--header=<N>

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

--round=<METHOD>

use METHOD for rounding when scaling

--suffix=<SUFFIX>

print SUFFIX after each formatted number, and accept inputs optionally ending with SUFFIX

--unit-separator=<STRING>

use STRING to separate the number from any unit when printing; by default, no separator is used

--invalid=<INVALID>

set the failure mode for invalid input

--zero-terminated, -z

line delimiter is NUL, not newline

Opciones de UNIDAD:

  • none: no se hace escalado automático; los sufijos activarán un error

  • auto: aceptar sufijo opcional de una/dos letras:

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

  • si: aceptar sufijo opcional de una letra:

    1K = 1000, 1M = 1000000, …

  • iec: aceptar sufijo opcional de una letra:

    1K = 1024, 1M = 1048576, …

  • iec-i: aceptar sufijo opcional de dos letras:

    1Ki = 1024, 1Mi = 1048576, …

  • CAMPOS soporta rangos de campo estilo cut(1):

    N N-ésimo campo, contado desde 1 N- desde el N-ésimo campo, hasta el final de la línea N-M desde el N-ésimo hasta el M-ésimo campo (inclusive) -M desde el primero hasta el M-ésimo campo (inclusive)

    • todos los campos

Múltiples campos/rangos pueden separarse con comas

FORMATO debe ser adecuado para imprimir un argumento de punto flotante %f. Comilla opcional (%’f) habilitará –grouping (si es soportado por la configuración regional actual). Valor de ancho opcional (%10f) rellenará la salida. Ancho cero opcional (%010f) rellenará el número con ceros. Valores negativos opcionales (%-10f) alinearán a la izquierda. Precisión opcional (%.1f) sobrescribirá la precisión determinada por la entrada.

Examples

Convierte 1.5K (Unidades SI) a 1500:

numfmt --from si 1.5K

Convierte el 5º campo (1-indexado) a Unidades IEC sin convertir la cabecera:

ls -l | numfmt --header=1 --field 5 --to iec

Convierte a unidades IEC, los rellena con 5 caracteres, alineado a la izquierda:

du {{[-s|--summarize]}} * | numfmt --to iec --format "%-5f"

The examples are provided by the tldr-pages project under the CC BY 4.0 License.

Please note that, as uutils is a work in progress, some examples might fail.