Search code examples
shellunixls

Does ls -l print the file size in blocks or bytes?


I created a new file on a unix server.

Now, ls -l prints the following:

-rwxr-xr-x 1 mccorm14 student 49508 Oct 26 11:29 4th

Does ls -l print the file size (49508) in blocks or bytes? If it is blocks, how do I convert it to bytes?


Solution

  • ls -l lists file sizes in bytes. No conversion necessary. For readability you can use -h to print human readable sizes like 49K.

    You may be thinking of du, which uses block size by default. For du try -h to print human readable sizes or -k to set the block size to 1KiB.