Skip to Content
gnux

--to

Auto-scale output numbers to UNITs; see UNIT below.

An option of numfmtx.

Usage

numfmtx --to=UNIT [NUMBER]...

Details

ShortLongValueDefaultMeaning
--toUNITauto-scale output numbers to UNITs; see UNIT below

Examples

Show a byte count the way people read sizes

numfmtx --to=iec 1048576
Output
1.0M

Use decimal units, as disk makers do

numfmtx --to=si 1500000
Output
1.5M

Make the size column of a listing readable, keeping the header

lsx -l | numfmtx --header --field=5 --to=iec

Round sizes down, never overstating them

numfmtx --to=si --round=down 1999
Output
1.9k

Add a unit and pad the numbers to a column

numfmtx --to=iec --suffix=B --padding=7 1024 2048000
Output
  1.0KB
  2.0MB

Convert the second column of a CSV file

numfmtx -d, --field=2 --to=si < sizes.csv

Keep going past values that are not numbers, but say which

numfmtx --invalid=warn --to=si 1000 n/a 2000

Help in the terminal

gnux help numfmtx --to

On this page