SnipIT No 3: Using “find” in Solaris: Part 1

SnipIT is a series of short blogs containing useful information in an easily digestible format.
find is a useful command in Solaris although it may not always be a straight forward matter using it to get what you want.
I have two examples which I use regularly and thought I’d share them with you…
1) List the files in the current directory and it’s sub-directories sorted by filesize showing their path and filename.
find . -type f -print | xargs ls -l | awk -F" " '{ print $5,$9 }' | sort -r -n
2) Sum the size of all the files in the current directoty and sub-directories.
find . -type f -print | xargs ls -l | awk '{ SUM += $5} END { print SUM/1024/1024 }'
The above examples specify -type f, this indicates that we are looking for files only.
I hope these prove as useful to you as they have for me!


Posted

in

by

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *