LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Puppy
User Name
Password
Puppy This forum is for the discussion of Puppy Linux.

Notices


Reply
  Search this Thread
Old 12-28-2014, 10:48 PM   #1
Fixit7
Senior Member
 
Registered: Mar 2014
Location: El Lago, Texas
Distribution: Ubuntu_Mate 16.04
Posts: 1,374

Rep: Reputation: 169Reputation: 169
Find largest files


I am trying to find the top 20 largest files on my linux partition.

None of the examples I have seen work.

The ones that work list files from every partition.

Does someone have an example I can study ?
 
Old 12-28-2014, 11:29 PM   #2
dijetlo
Senior Member
 
Registered: Jan 2009
Location: RHELtopia....
Distribution: Solaris 11.2/Slackware/RHEL/
Posts: 1,491
Blog Entries: 2

Rep: Reputation: Disabled
Hey Fixit,

It seems that part of the problem may be how are you identifying which partition is the linux partition?

du <insert path to partition> | sort -n -r | head -n 20

works fine if you know what the path to the partition you want to look at is.

as an example, on one instance, /usr/local/ is a separate partition (/dev/sda5) I could use

du /usr/local/ | sort -n -r | head -n 20

to get that information about the files in /usr/local

If your entire installation is on one particular partition and you want metrics on that partition, the simplest way to do that is...

du | sort -n -r | head -n 20
which will give you the largest 20 (minus any permission denied error messages)
 
Old 12-29-2014, 09:07 AM   #3
Fixit7
Senior Member
 
Registered: Mar 2014
Location: El Lago, Texas
Distribution: Ubuntu_Mate 16.04
Posts: 1,374

Original Poster
Rep: Reputation: 169Reputation: 169
Thanks dijetlo.

It looks like it shows the 20 largest directories which is helpful in showing where the large files are.

What about showing the 20 largest files themselves ?

Quote:
# du | sort -n -r | head -n 20
752000 .
359712 ./.wine
358732 ./.wine/drive_c
259556 ./.wine/drive_c/windows
233912 ./.cache
167552 ./.cache/mozilla
131124 ./.wine/drive_c/windows/mono
131120 ./.wine/drive_c/windows/mono/mono-2.0
109416 ./.cache/mozilla/firefox
109412 ./.cache/mozilla/firefox/cavkygim.default
105056 ./.wine/drive_c/windows/mono/mono-2.0/lib
105052 ./.wine/drive_c/windows/mono/mono-2.0/lib/mono
104356 ./.cache/mozilla/firefox/cavkygim.default/Cache
74280 ./.wine/drive_c/users
74220 ./.wine/drive_c/users/root
70340 ./.wine/drive_c/users/root/Local Settings
70320 ./.wine/drive_c/users/root/Local Settings/Temporary Internet Files
70316 ./.wine/drive_c/users/root/Local Settings/Temporary Internet Files/Content.IE5
66332 ./.wine/drive_c/windows/Installer
66332 ./.cache/wine
 
Old 12-29-2014, 09:14 PM   #4
veerain
Senior Member
 
Registered: Mar 2005
Location: Earth bound to Helios
Distribution: Custom
Posts: 2,524

Rep: Reputation: 319Reputation: 319Reputation: 319Reputation: 319
Use the find command with -size option like:

Code:
find / -size +100M
And you have to adjust the size parameter until find the best one or after closing on approximately you use individual du command on them and sort with 'sort' command.
 
Old 12-29-2014, 09:42 PM   #5
schneidz
LQ Guru
 
Registered: May 2005
Location: boston, usa
Distribution: fedora-35
Posts: 5,313

Rep: Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918
Code:
[schneidz@hyper ~]$ cat bin/space.ksh
#!/bin/bash



sudo find / -type f -printf "%s \t\t%p\n" | sort -nr > ~/file-sizes.txt
sudo find / -type d -exec du -b -d 0 -S '{}' \; | sort -nr > ~/dir-sizes.txt

df -h
 
Old 12-29-2014, 10:11 PM   #6
dijetlo
Senior Member
 
Registered: Jan 2009
Location: RHELtopia....
Distribution: Solaris 11.2/Slackware/RHEL/
Posts: 1,491
Blog Entries: 2

Rep: Reputation: Disabled
Quote:
find . -type f -exec ls -s {} \; | sort -n -r | head -20
Replace the '.' after find with the root of the file system you want searched.
Warning, depending on how many files this thing is going to process, it can take a while.
 
Old 12-29-2014, 10:38 PM   #7
Fixit7
Senior Member
 
Registered: Mar 2014
Location: El Lago, Texas
Distribution: Ubuntu_Mate 16.04
Posts: 1,374

Original Poster
Rep: Reputation: 169Reputation: 169
Thanks for the help.

Would be nice to filter out those "ls: cannot access ./mnt/sdb1/TOSHIBA_SDB1: No such file or directory"
lines. :-)
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Bash script to read through text files and find largest number in files pomico Programming 15 09-13-2012 01:07 PM
Find largest file within a directory grob115 Programming 5 09-04-2011 02:35 AM
Command to find largest file. paragkalra Linux - Software 2 11-17-2009 04:36 AM
how do i find the largest file on machine amit_joshi Linux - Newbie 4 10-08-2007 07:09 PM
Find 100 largest files in folder tree tyreth Linux - General 2 02-07-2006 08:18 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Puppy

All times are GMT -5. The time now is 07:00 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration