Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

HP-UX Large Files

Posted on 2006-11-06
11
Medium Priority
?
1,096 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
Independent Software Vendors: 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!

 
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

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

Question has a verified solution.

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

Attention: This article will no longer be maintained. If you have any questions, please feel free to mail me. jgh@FreeBSD.org Please see http://www.freebsd.org/doc/en_US.ISO8859-1/articles/freebsd-update-server/ for the updated article. It is avail…
My previous tech tip, Installing the Solaris OS From the Flash Archive On a Tape (http://www.experts-exchange.com/articles/OS/Unix/Solaris/Installing-the-Solaris-OS-From-the-Flash-Archive-on-a-Tape.html), discussed installing the Solaris Operating S…
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.:
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
Suggested Courses

926 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