Get File Size in Terminal

Updated on

For a single file:

ls -l example.txt | awk '{print $5}'

For all files in a folder, sorted smallest to largest:

ls -l | awk '{print $5, $9}' | sort -n

For all files in folders and subfolders:

find . -type f -exec ls -l {} + | awk '{print $5, $9}' | sort -n