The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
largest field , awk , help jkl_jkl Shell Programming and Scripting 5 03-15-2008 11:23 PM
find the 5o largest files in a directory igidttam Filesystems, Disks and Memory 8 05-16-2007 10:20 AM
file of largest size in pwd rameshparsa Shell Programming and Scripting 4 11-22-2005 08:25 AM
Finding largest file in current directory? AusTex High Level Programming 1 03-13-2005 09:03 AM

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 07-02-2007
Registered User
 

Join Date: Feb 2007
Posts: 109
Stumble this Post!
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
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 07-02-2007
Registered User
 

Join Date: May 2007
Posts: 211
Stumble this Post!
This will bring the largest file in the directory. But if the directory has the maximum size then it would list the directory rather than the files.

Code:
du -ms * | sort | tail -1
Reply With Quote
  #3 (permalink)  
Old 07-02-2007
Registered User
 

Join Date: Feb 2007
Posts: 109
Stumble this Post!
I was getting the below error ,OS is HP unix

$ du -ms * | sort | tail -1
du: illegal option -- m
usage: du [-a|-s] [-kbrx] [-t type] [name ...]


Thanks ,
Mohan
Reply With Quote
  #4 (permalink)  
Old 07-02-2007
Registered User
 

Join Date: May 2007
Posts: 211
Stumble this Post!
My OS is an Linux version one, let me check out for the HP-UX.
Reply With Quote
  #5 (permalink)  
Old 07-03-2007
Registered User
 

Join Date: Jun 2007
Posts: 2
Stumble this Post!
Try using the following command,

du -a | sort -n | tail -2 | head -1 | cut -f2

Thanks,
Seetharaman
Reply With Quote
  #6 (permalink)  
Old 07-03-2007
Registered User
 

Join Date: Feb 2007
Posts: 109
Stumble this Post!
Hi,

Its working for less file size ,can u explain the syntax.

Thanks,
Mohan
Reply With Quote
  #7 (permalink)  
Old 07-03-2007
Registered User
 

Join Date: Jun 2007
Posts: 2
Stumble this Post!
Can you just tell me if there is any problem if the file size is larger???

Thanks,
Seetharaman
Reply With Quote
Google The UNIX and Linux Forums
Reply

Tags
linux

Thread Tools
Display Modes




All times are GMT -7. The time now is 05:28 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008 The CEP Blog All Rights Reserved -Ad Management by RedTyger Visit The Global Fact Book

Content Relevant URLs by vBSEO 3.2.0