To Find the largest file in the given directory.


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting To Find the largest file in the given directory.
# 1  
Old 05-22-2010
To Find the largest file in the given directory.

Hi Experts,

1. In unix how to list the largest file in given directory.
The answer will in single line statement.

2. I have Sun solaris live CD .I try to compile sample c program using "CC compiler".But its shows "cc command not found".
Please help on this.

Thanks in advance....

Last edited by kkl; 05-22-2010 at 11:20 PM.. Reason: Added one more queries.
# 2  
Old 05-23-2010
1. In unix how to list the largest file in given directory.
The answer will in single line statement.

Code:
# du -akd /directory_name|sort -nr|more    ---->>> to list files from largest to smallest on the "/directory_name"

2. I have Sun solaris live CD .I try to compile sample c program using "CC compiler".But its shows "cc command not found".
Please help on this.

Code:
Post the exect error which you are getting.
May be you are using some strange command which is unknow to the system.

Smilie
This User Gave Thanks to Reboot For This Post:
# 3  
Old 05-23-2010
Hi, an easier way to achieve (1) is:

Code:
ls -S|head -1

i.e. list files sorted on size, and show the top entry.

As for (2), there is no program cc in Your search path for programs. Either the C Compiler isn't included or You may need to install it or make it available in some way. Since it's a Live CD it may or may not be possible to install a compiler. I guess You must read the documentation for that particular release/Live CD.

Best regards,
Lakris

Last edited by Lakris; 05-23-2010 at 06:41 AM..
This User Gave Thanks to Lakris For This Post:
# 4  
Old 05-23-2010
Code:
<esb><***-app-***-03> /export/home/esb/temp # ls -S|head -1
ls: illegal option -- S
usage: ls -1RaAdCxmnlhogrtuvVcpFbqisfHLeE@ [files]

It is not working Smilie

---------- Post updated at 03:29 PM ---------- Previous update was at 03:16 PM ----------

Hii kkl,

I am using find command to get large files whenever the disc space spikes.

Code:
find * -size +100000  # for 100 MB files.
#you can use these too
du -k * | sort -n | tail -10
du -ka | sort -nrk1 | tail -10


Last edited by Scott; 05-23-2010 at 06:52 AM.. Reason: Code tags please...
This User Gave Thanks to KuldeepSinghTCS For This Post:
# 5  
Old 05-23-2010
Quote:
Originally Posted by KuldeepSinghTCS
Code:
<esb><***-app-***-03> /export/home/esb/temp # ls -S|head -1
ls: illegal option -- S
usage: ls -1RaAdCxmnlhogrtuvVcpFbqisfHLeE@ [files]

It is not working Smilie

---------- Post updated at 03:29 PM ---------- Previous update was at 03:16 PM ----------

Hii kkl,

I am using find command to get large files whenever the disc space spikes.

Code:
find * -size +100000  # for 100 MB files.
#you can use these too
du -k * | sort -n | tail -10
du -ka | sort -nrk1 | tail -10

Thanks To ALL..

For Query 2 :
I compile with sun solaris live CD.I tried in Ubuntu live CD also.
Both getting same problem..
It getting displayed like below,

cc new.c
bash: command not found.

I put which cc and gcc no bin is found /usr/bin..

Plz help to resolve this..
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Command to find largest file.

Hi All, Is there a direct Linux command to find the largest file by checking recursively in all the directories. (3 Replies)
Discussion started by: paragkalra
3 Replies

2. 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

3. Shell Programming and Scripting

Find largest files

Hello, i am on linux 2.6.13-1.1526_FC4smp , and i would be very greatfull if someone could help to find the largest files on that server. I know i can find files with find command or list them with ls , but is there a way that i could list let's say 10 biggest files on server ? :o (11 Replies)
Discussion started by: tonijel
11 Replies

4. 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

5. Shell Programming and Scripting

Find and display largest file on system

What is the correct command for finding and displaying the largest file on the system? I don't know how to specify "largest" with "find", and pipe that to something that will display the file contents. Or should I be using cat, more, less, ls, or something else? (4 Replies)
Discussion started by: raidkridley
4 Replies

6. HP-UX

find the largest file in whole system

find the largest file in whole system (7 Replies)
Discussion started by: megh
7 Replies

7. Shell Programming and Scripting

find largest file

Hi, 1)I have XX directory and have lot of files ,I want to find largest file in that directory 2)how calculate the size of file in MB. Thanks, Mohan (15 Replies)
Discussion started by: mohan705
15 Replies

8. 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

9. UNIX for Advanced & Expert Users

largest size directory in unix

I want to find the which directory under a directory occupy the maximum size is there is any command to find please help (5 Replies)
Discussion started by: arunkumar_mca
5 Replies

10. Programming

Finding largest file in current directory?

I was hoping to get some assistance with this C program I am working on. The goal is to find the largest file in the current directory and then display this filename along with the filesize. What I have so far will display all the files in the current directory. But, how do I deal with "grabbing"... (1 Reply)
Discussion started by: AusTex
1 Replies
Login or Register to Ask a Question