Solved

HP-UX Large Files

Posted on 2006-11-06
11
1,033 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
Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

 
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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Python Assistance 7 81
Unix Script: Loop over all days of a month 17 99
awk sed variable in file 3 38
centos commands 6 54
Java performance on Solaris - Managing CPUs There are various resource controls in operating system which directly/indirectly influence the performance of application. one of the most important resource controls is "CPU".   In a multithreaded…
FreeBSD on EC2 FreeBSD (https://www.freebsd.org) is a robust Unix-like operating system that has been around for many years. FreeBSD is available on Amazon EC2 through Amazon Machine Images (AMIs) provided by FreeBSD developer and security office…
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…
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.

778 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