How to convert file size to human readable and print with other columns?
07:45 17 Jun 2022

I want to convert the 5th column in this command output to human readable format. For ex if this is my input :

-rw-rw-r-- 1 bhagyaraj bhagyaraj  280000   Jun 17 18:34 demo1
-rw-rw-r-- 1 bhagyaraj bhagyaraj  2800000  Jun 17 18:34 demo2
-rw-rw-r-- 1 bhagyaraj bhagyaraj  28000000 Jun 17 18:35 demo3

To something like this :

-rw-rw-r--  280K demo1
-rw-rw-r--  2.8M demo2
-rw-rw-r--  28M  demo3

I tried this command, but this will return only the file size column.

ls -l | tail -n +2 |awk '{print $5 | "numfmt --to=si"}'

ls is just for example my use case is very huge and repeated execution must be avoided

Any help would be appreciated :)

bash shell