- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Finding largest file within a filesystem/disk
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-03-2002 11:26 PM
06-03-2002 11:26 PM
Is there a command in UNIX which allows us to retrive the LARGEST file/directory within a filesystem/disk-partition?
Or if there aren't, then could someone an example of a script which actually searches efficiently through the filesystem and list the largest fille/dir?
Thanks.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-03-2002 11:32 PM
06-03-2002 11:32 PM
Re: Finding largest file within a filesystem/disk
You can do it by find command with the -size flag:
-size n[c] True if the file is n blocks long (512 bytes
per block). If n is followed by a c, the
size is in bytes.
Take a look at the man page for find.
Regards,
Justo.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-03-2002 11:34 PM
06-03-2002 11:34 PM
SolutionHere is a script that I find useful. Hope it helps.
#######################################
#!/bin/sh
if [ $# -eq 2 ]
then
find $1 -type f -xdev -size +$(expr "$2" \* 2) -exec ll -d {} \;
else
echo "Usage : ${0##*/}
fi
#######################################
Use it like this:
./largefiles.sh /var 20000
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-03-2002 11:36 PM
06-03-2002 11:36 PM
Re: Finding largest file within a filesystem/disk
with the find command you can do this ie:
find
which will show you files within
Regards
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-04-2002 01:03 AM
06-04-2002 01:03 AM
Re: Finding largest file within a filesystem/disk
here my solution for you:
ls -Ral | grep -v total |grep -v '^d' | awk '{print $5,$9}' | sort -k1n
does the following:
--> makes a recursive listing of all contents under current position
--> gets rid of total entries
--> gets rid of all directories
--> filters out size of files
--> does a numeric sort, biggest files are last in the output.
--> output is only size and name of files
Allways stay on the bright side of life!
Peter
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-04-2002 03:35 AM
06-04-2002 03:35 AM
Re: Finding largest file within a filesystem/disk
find / -type f -size +1000000c -exec ls -ls {} \; | sort -rn | more
Reduce the size from a million (1000000) to less if you want the "base" search to look at smaller files.
Change the "/" to a "." if you want to "cd" into a directory and look for the largest file:
cd somedirectory
find . -type f -size +10000c -exec ls -ls {} \; | sort -rn | more
live free or die
harry
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-04-2002 04:23 AM
06-04-2002 04:23 AM
Re: Finding largest file within a filesystem/disk
Always look for big directories first! And here is the easiest way:
du -kx / | sort -rn > /tmp/du.slash
Go through each mountpoint, especially /var and /usr. The output of the command is a list of the biggest directories first (in Kbytes). Once you find a big directory that doesn't look right, see if there is a big subdirectory inside where most of the space is used. At that point, use ll to locate the big files like this:
ll | sort -rnk5 | more
Please do not remove any big files until you determine why the file exists. New sysadmins will see the vmunix files and figure these are unrelated to HP-UX...
Bill Hassell, sysadmin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-04-2002 04:51 AM
06-04-2002 04:51 AM
Re: Finding largest file within a filesystem/disk
if you have a lot of cpu time and even more patience, you could try the attached script.
regards
John Korterman