list largest files in a directory & its subdirectories


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers list largest files in a directory & its subdirectories
# 1  
Old 09-25-2006
list largest files in a directory & its subdirectories

I need to find the largest files in a directory & it's subdirectories.
I'm not sure what options on ls -l will work to give me this. or is there another way to do this?
Thanks,
igidttam
# 2  
Old 09-25-2006
For example, to show the 10 largest files under /somedir and it's subdirectories:

Code:
find /somedir -type f -print | xargs ls -l | sort -k5,5rn | head

Cheers
ZB
# 3  
Old 09-25-2006
ZB

I'm getting an error. xargs| Child killed with signal 13.
How would I get around this?
Thakn You for your help!
igidttam
# 4  
Old 09-25-2006
I changed the code a little to this
find /cep -type f -print | ls -l | head
It worked, but not sure I have all the files in the subdirectories.
Can someone help me here?

Thanks
igidttam
# 5  
Old 09-25-2006
if you know what files are supposed to be there and /cep is the directory off of the root directory / you want to search
Code:
find /cep -type f -print

will show you all the files you are looking at

Code:
cd /home
find . -type f -print | ls -l -s | sort -n | tail

does in fact give me the biggest files. You would use
Code:
cd /cep

# 6  
Old 09-25-2006
Thanks Jim! This works, but only gives me the largest files in that directory [in my example the /cep directory]. I'm also looking for the largest files within each of the subdirectories of that directory. For example, I want the 10 largest files of some directory and the 10 largest files of each subdirectory under that directory. How do I do that?

Thanks,
igidttam
# 7  
Old 09-25-2006
I go t it to work. I needed the ls -lR.

Thanks Jim
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Append string to all the files inside a directory excluding subdirectories and .zip files

Hii, Could someone help me to append string to the starting of all the filenames inside a directory but it should exclude .zip files and subdirectories. Eg. file1: test1.log file2: test2.log file3 test.zip After running the script file1: string_test1.log file2: string_test2.log file3:... (4 Replies)
Discussion started by: Ravi Kishore
4 Replies

2. Shell Programming and Scripting

List files with *.i extension in a directory and all its subdirectories + 30days old then remove

I need to write a script to : list files with *.i extension in a directory and all its subdirectories + 30days old, save it in a file and then remove (2 Replies)
Discussion started by: lena keung
2 Replies

3. Shell Programming and Scripting

How to list all Subdirectories and files with its full path in a parent directory?

How to list all Subdirectories and files with its full path in a parent directory? (1 Reply)
Discussion started by: johnveslin
1 Replies

4. UNIX for Dummies Questions & Answers

How to search & list subdirectories with the given file name

Question: How to search & list subdirectories with the given file name? For example: The directory structure looks like; /Builds/DEV/Build_RL01/DDL/ a_tbl_cre.sql ...... /Builds/DEV/Build_RL01/DML/ a_upd.sql .... .... Requirements: 1. I need to find subdirectory DML which is... (0 Replies)
Discussion started by: Siva SQL
0 Replies

5. Shell Programming and Scripting

how can i find number of lines in files & subdirectories

how can i find number of lines in files & subdirectories ? (3 Replies)
Discussion started by: pcbuilder
3 Replies

6. UNIX for Dummies Questions & Answers

list largest files

hi all, i want to list the five largest files in current directory ... . (3 Replies)
Discussion started by: sonu_pal
3 Replies

7. UNIX for Dummies Questions & Answers

Best way to find largest files in a directory

What is the best way to find the largest files in a directory? I used du -k|sort -rn |less. I got a results for this. But if I used the following command , I got another result...a different order in the same directory. Why is that? ls -la |awk '{print $5," ",$9}' sort -rn|less. I saw that... (6 Replies)
Discussion started by: Pouchie1
6 Replies

8. UNIX for Dummies Questions & Answers

How to find the list of 5 largest file in current directory?

Hello, How to find the list of 5 largest(size wise) file in current directory?i tried using ls -l | sort -t " " -r +5 -6 -n | head -5 but this is not giving correct output as ls -l command gives 1 extra line of output that is how many total files are there!so by running the above... (4 Replies)
Discussion started by: salman4u
4 Replies

9. Shell Programming and Scripting

search files in a directory and its subdirectories

Hello my friends, I need to write a simple shell bad file :D that search and delete a file it's name 'Microsoft.txt' in the current directory and its subdirectories? So can you help to guide me how i can write this shell, Just give me the beginning :o thank you. (1 Reply)
Discussion started by: Net-Man
1 Replies

10. Filesystems, Disks and Memory

find the 5o largest files in a directory

I'm trying to find the 50 largest file in a directory named /sasdb and its' subdirectories. I'm using the find command and a pipe to awk Not sure if I'm actually getting the largest files from this directory and its subdirectories. Here is the code I used... find /sasdb -ls | awk '{print... (8 Replies)
Discussion started by: igidttam
8 Replies
Login or Register to Ask a Question