Simplest method to convert file-size with suffix to bytes

前端 未结 6 409
深忆病人
深忆病人 2021-01-03 10:45

Title says it all really, but I\'m currently using a simple function with a case statement to convert human-readable file size strings into a size in bytes. It works well en

6条回答
  •  南方客
    南方客 (楼主)
    2021-01-03 11:15

    See man numfmt.

    # numfmt --from=iec 42 512K 10M 7G 3.5T
    42
    524288
    10485760
    7516192768
    3848290697216
    
    # numfmt --to=iec 42 524288 10485760 7516192768 3848290697216
    42
    512K
    10M
    7.0G
    3.5T
    

提交回复
热议问题