?
Solved

HP-UX Large Files

Posted on 2006-11-06
11
Medium Priority
?
1,076 Views
Last Modified: 2013-12-06
I need to search through a directory and all it's sub directories and print out the top files by size

what is the best way to print out, say the 10 largest files in a directory and it's sub directories, or at least all files over a certain size... say 500mb.
This is on a HP-UX box which is an annoyingly different version of unix

Thanks

Gav
0
Comment
Question by:gavcol
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
  • 3
11 Comments
 
LVL 38

Expert Comment

by:yuzh
ID: 17887091
you can use "find" command with -size n (where n=512b block)

eg for file > 100MB under current dir

find . -type f -size +200000 -print

for 500MB
find . -type f -size +1000000 -print

man find
to learn more details
0
 

Author Comment

by:gavcol
ID: 17887167
Thanks Yuzh,
  It is good that I get the path to each file but it doesn't give me the size of each file and therefore I am unable to determine which ones are the largest ??

Cheers

Gav

0
 
LVL 58

Expert Comment

by:amit_g
ID: 17887349
find . -type f | xargs wc -c | sort -nr -t " " -k1 | grep -v "total$" | head -1
0
Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

 
LVL 38

Expert Comment

by:yuzh
ID: 17887590
To see the filesize owner permission sort by file size, you can do:
> 100MB:
find . -type f -size +200000 -ls | sort -k 7
>500MB:
find . -type f -size +1000000 -ls | sort -k 7
0
 

Author Comment

by:gavcol
ID: 17894684
Sorry guys,
   
amit_g... your example just gave me a list of files with "wc:cannot open file" at the start of every line and no filesizes

yuzh.... yours returned "find: bad option -ls"

Results don't have to be sorted.  I'll > file.txt and sort later

Thanks again for your help.  I hope we can sort this

0
 
LVL 58

Accepted Solution

by:
amit_g earned 600 total points
ID: 17894774
Does this work for you?

find . -type f -exec ls -l {} \;

If so, sort it by

find . -type f -exec ls -l {} \; | sort -nr -k 5

and to get just top 1

find . -type f -exec ls -l {} \; | sort -nr -k 5 | head -1
0
 
LVL 38

Assisted Solution

by:yuzh
yuzh earned 500 total points
ID: 17894902
I just did a test on an HP-UX box,

find . -type f -size +200000 -exec ls -l {} \; | sort -nr -k 5

or
find . -type f -size +200000 -exec ls -l {} \; | sort  -k 5

works fine, please give some  credit to amit_g
0
 

Author Comment

by:gavcol
ID: 17894921
Thanks amit_g
 
That worked a treat ... though it took ages to run as it listed ALL files so I did modify it to  

find . -type f -size +200000 -exec ls -l {} \; | sort -nr -k 5 > filesize.txt

Thanks for your help
Muchly appreciated

Gav
0
 

Author Comment

by:gavcol
ID: 17894983
Bugger,
   sorry amit_g.  after I replied to your response I just accepted the last comment above my post thinking it was yours but Yuzh had just jumped in so yuzh got the points.

Really sorry.  can this be fixed or modified so I can split the points ???

Gav

0
 
LVL 58

Expert Comment

by:amit_g
ID: 17895194
Thanks gavcol and yuzh :)
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In tuning file systems on the Solaris Operating System, changing some parameters of a file system usually destroys the data on it. For instance, changing the cache segment block size in the volume of a T3 requires that you delete the existing volu…
This tech tip describes how to install the Solaris Operating System from a tape backup that was created using the Solaris flash archive utility. I have used this procedure on the Solaris 8 and 9 OS, and it shoudl also work well on the Solaris 10 rel…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
Suggested Courses

801 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question