The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
Google UNIX.COM


UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
help me in sending parameters from sqlplus script to unix shell script Hara Shell Programming and Scripting 2 01-29-2008 12:31 PM
Shell Script: want to insert values in database when update script runs ring Shell Programming and Scripting 1 10-25-2007 12:06 AM
here document to automate perl script that call script hogger84 Shell Programming and Scripting 3 10-22-2007 07:15 AM
returning to the parent shell after invoking a script within a script gurukottur Shell Programming and Scripting 5 09-26-2006 04:05 AM
return valuse from child script to parent script borncrazy Shell Programming and Scripting 1 08-20-2004 12:39 PM

Closed Thread
 
Submit Tools LinkBack Thread Tools Display Modes
  #1  
Old 12-19-2001
Registered User
 

Join Date: Dec 2001
Posts: 8
please help script

Could someone please tell me the code to list the total disk usage for a certain user on a unix system. I think I might need to use a pipe but am unsure please help
thx in advance
Forum Sponsor
  #2  
Old 12-19-2001
Registered User
 

Join Date: Jul 2001
Posts: 62
Hi,

TRY THIS:
df -t /usr

Report the total allocated block figures and the number of free
blocks, for the file system mounted as /usr:
so you can put the path of the user you wish to see instead of /usr.

Good luck. Hope that helps.
Bye
Rooh

  #3  
Old 12-20-2001
Registered User
 

Join Date: Dec 2001
Posts: 8
thanks

thanks mate, will try that
  #4  
Old 12-26-2001
Registered User
 

Join Date: Sep 2001
Location: Johanessburg
Posts: 27
Try using this

Insert the following into a file called "dusage"
Code:
##########################################PN=`basename "$0"`                      # Program name
VER=`echo '$Revision: 1.2 $' | cut -d' ' -f2`
if [ $# = 0 ]
then
echo "Please Enter Directory Name:\c"
read PROG
else
PROG=$1
fi
# Determine mail spool directory (BSD/SYSV)
for MailDir in "$PROG"
do
    [ -d "$MailDir" -a -r "$MailDir" ] && break
done

Usage () {
    echo >&2 "$PN - show top 10 directory users, $VER (hs '94)
usage: $PN [directory ...]

If no directory is specified, $MailDir is the default."
    exit 1
}

[ $# -gt 0 -a "$1" = "-h" ] && Usage

# set the default directory
[ $# -lt 1 ] && set $MailDir

echo "NAME                     BYTES    FILES   PERCENT"
ls -lL "$@" |
    awk '
        (NF == 8 || NF == 9 ) {                 # BSD or SYSV
            # example of a line:
            # -rw-------  1 andrea     286282 Oct 21 11:24 andrea
            #           or
            # -rw-------  1 andrea entw  286282 Oct 21 11:24 andrea
            Usage [$3] += $(NF-4)       # used bytes, username is index
            Count [$3]++
            TotalBytes += $(NF-4)
        }
        END {
            for ( user in Usage )
                printf "%-15s %12d      %d      %2d\n", \
                    user, Usage [user], Count [user], \
                    Usage [user] * 100 / TotalBytes
        }
    ' | sort -nr +1 | head
exit 0
##########################################
as soon as that's done wq! and change the file prority to rwxrwx

like this
chmod 770 dusage

now if you have root access move dusage to /usr/sbin

then move back to your home dirr and type in

dusage
it will then ask you what dirr you would like to check

The outcome and advantage of this is that it shows you the block space in % and the user taking up that space.

Have Fun
Marcus.

added code tags for readability --oombera

Last edited by oombera; 02-18-2004 at 08:58 AM.
Google The UNIX and Linux Forums
Closed Thread

Thread Tools
Display Modes




All times are GMT -7. The time now is 02:08 AM.


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

Content Relevant URLs by vBSEO 3.2.0