Simplest method to convert file-size with suffix to bytes

前端 未结 6 411
深忆病人
深忆病人 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:21

    toBytes() {
     echo $1 | echo $((`sed 's/.*/\L\0/;s/t/Xg/;s/g/Xm/;s/m/Xk/;s/k/X/;s/b//;s/X/ *1024/g'`))
    }
    

提交回复
热议问题