Skip to content

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

13/01/2012

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!

Advertisements

From → Unix/Linux

Leave a Comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: