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 and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
disk usage (df vs du) gfhgfnhhn UNIX for Advanced & Expert Users 8 09-23-2006 09:06 PM
disk usage karthikosu UNIX for Dummies Questions & Answers 2 06-29-2006 04:48 PM
Disk Usage lewisoco UNIX for Dummies Questions & Answers 3 05-09-2006 09:44 PM
Disk usage (Mac OS 10.4) H1tokori UNIX for Dummies Questions & Answers 5 12-05-2005 07:37 PM
disk usage asutoshch UNIX for Dummies Questions & Answers 4 04-01-2001 09:02 AM

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 08-13-2007
harikamamidala harikamamidala is offline
Registered User
  
 

Join Date: Jul 2007
Posts: 7
Disk Usage

Hi,

I want to retrieve the directory in the shell script that is using maximum space on the disk.I was using du command but it displays all the directories that are using the space on the disk.How can retrieve the only directory which uses the maximum space on the disk??

Thanks in advance.

Regards,
Harika Mamidala
  #2 (permalink)  
Old 08-13-2007
matrixmadhan matrixmadhan is offline Forum Advisor  
Technorati Master
  
 

Join Date: Mar 2005
Location: leaf node in B+ tree
Posts: 2,958
something like this

Code:
du -sk * | sort -nr | more

  #3 (permalink)  
Old 08-13-2007
robotronic's Avatar
robotronic robotronic is offline Forum Advisor  
Can I play with madness?
  
 

Join Date: Apr 2002
Location: Italy
Posts: 370

Code:
du -sk * | sort -n | tail -1

  #4 (permalink)  
Old 08-16-2007
harikamamidala harikamamidala is offline
Registered User
  
 

Join Date: Jul 2007
Posts: 7
Hi,

Thanks for ur reply.I am able to get the directory name thats occupying the maximum space using .. ls |du -sk * | sort -n | tail -1 | cut -f2

Is there anyway that I can get the directory that uses more than 80% of the disk space instead of mentioning the directory that uses the maximum space.

Thanks & Regards,
Harika Mamidala
  #5 (permalink)  
Old 08-16-2007
robotronic's Avatar
robotronic robotronic is offline Forum Advisor  
Can I play with madness?
  
 

Join Date: Apr 2002
Location: Italy
Posts: 370

Code:
TOT_KB=`df -k . | tail -1 | awk '{ print $2 }'`
du -sk * | awk '{ if ($1 > ('$TOT_KB'*0.8)) print; }' | sort -n

Closed Thread

Bookmarks

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 06:40 PM.


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