Sometime we need to get file size for the purpose of automation in bash shell script. Here are few ways to get a size of file in bytes on Linux and Mac.
print file bytes using stat
Linux
// Use gstat on Mac $ stat --format="%s" img1.png 47628
print file bytes using wc -c
$ wc -c img1.png 47628
print file bytes using ls
$ ls -l img1.png -rw-r--r--@ 1 pkjain staff 47628 Dec 4 23:23 img1.png