Solved

HP-UX Large Files

Posted on 2006-11-06
11
1,053 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
  • 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
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

 
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 150 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 125 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Installing FreeBSD… FreeBSD is a darling of an operating system. The stability and usability make it a clear choice for servers and desktops (for the cunning). Savvy?  The Ports collection makes available every popular FOSS application and packag…
Introduction Regular patching is part of a system administrator's tasks. However, many patches require that the system be in single-user mode before they can be installed. A cluster patch in particular can take quite a while to apply if the machine…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
In a previous video, we went over how to export a DynamoDB table into Amazon S3.  In this video, we show how to load the export from S3 into a DynamoDB table.

809 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