The most basic command to find file size of a given file is:
du -sm myfile.txt
If you are in a folder with multiple files and want to get file sizes of all the files, the command is:
du -sm *
The above command does not get file sizes recursively. However, if you are happy with it and want to sort the file sizes in ascending order:
du -sm * | sort -n -k 1
Now, this is little useful as it does not do recursive file size listing. To do that:
find . -type f -exec du -sm {} \; -print | sort -n -k 1
If you are looking for a particular type of file (eg. jar files):
find . -name "*.jar" -type f -exec du -sm {} \; -print | sort -n -k 1
Enjoy!
No comments:
Post a Comment