The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

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 and shell scripting languages 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 6 11-29-2008 06:21 PM
find the 5o largest files in a directory igidttam Filesystems, Disks and Memory 8 05-16-2007 01:20 PM
file of largest size in pwd rameshparsa Shell Programming and Scripting 4 11-22-2005 12:25 PM
Finding largest file in current directory? AusTex High Level Programming 1 03-13-2005 01:03 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 07-03-2007
mohan705 mohan705 is offline
Registered User
  
 

Join Date: Feb 2007
Posts: 134
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
  #2 (permalink)  
Old 07-03-2007
lorcan lorcan is offline
Registered User
  
 

Join Date: May 2007
Posts: 219
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
  #3 (permalink)  
Old 07-03-2007
mohan705 mohan705 is offline
Registered User
  
 

Join Date: Feb 2007
Posts: 134
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
  #4 (permalink)  
Old 07-03-2007
lorcan lorcan is offline
Registered User
  
 

Join Date: May 2007
Posts: 219
My OS is an Linux version one, let me check out for the HP-UX.
  #5 (permalink)  
Old 07-03-2007
ramnayakam ramnayakam is offline
Registered User
  
 

Join Date: Jun 2007
Posts: 2
Try using the following command,

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

Thanks,
Seetharaman
  #6 (permalink)  
Old 07-03-2007
mohan705 mohan705 is offline
Registered User
  
 

Join Date: Feb 2007
Posts: 134
Hi,

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

Thanks,
Mohan
  #7 (permalink)  
Old 07-03-2007
xramm xramm is offline
Registered User
  
 

Join Date: May 2007
Posts: 113
Quote:
Originally Posted by ramnayakam View Post
Try using the following command,

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

Thanks,
Seetharaman
It is working for find the bigger file size in current directory both in HP-UX and in Linux (open Suse). But if there is a bigger sized directory around it will point that.
Closed Thread

Bookmarks

Tags
linux

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 04:49 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0