Reputation: 87
I want to get the largest files along with sizes in MB, as I'm new to unix I searches in google and found this command
find . -type f -printf "%s : %p \n" | sort -nr | head -n 10
%s is giving the size of file in bytes, and by replacing it with %k size been converted to KB.
Is there any option that can convert the size of file in MB
Thanks in advance.
Upvotes: 1
Views: 338
Reputation: 74615
A quick and easy way to do this would be to pipe the output to awk:
$ find . -type f -printf "%k : %p \n" | awk '{$1/=1024}1' | sort -nr | head -n 10
The first column is divided by 1024 and the 1
at the end is a shorthand for {print}
, so each line is included in the output.
Upvotes: 1