Solved

HP-UX Large Files

Posted on 2006-11-06
11
1,011 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
 
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
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

 
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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Suggested Solutions

Why Shell Scripting? Shell scripting is a powerful method of accessing UNIX systems and it is very flexible. Shell scripts are required when we want to execute a sequence of commands in Unix flavored operating systems. “Shell” is the command line i…
Every server (virtual or physical) needs a console: and the console can be provided through hardware directly connected, software for remote connections, local connections, through a KVM, etc. This document explains the different types of consol…
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.
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.

707 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now