I am wanting to use the ls command to output the files in a directory however I need the file size in bytes.
Is this possible with the ls command?
on similar questions i've found this ls -l --block-size=M
which outputs the file size in megabytes however I cannot seem to get it to work with just bytes.
If you are looking for statistics about files, then you want to use stat
rather than ls
. eg, with gnu stat:
stat --format=%n:%s *
$ ls -l foo.tar.gz
-rw-r--r-- 1 james james 68964464 Mar 12 2014 foo.tar.gz
On my ls (GNU coreutils) 8.26
:
$ ls -s --block-size=1 foo.tar.gz
68972544 foo.tar.gz
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With