LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 09-20-2004, 09:44 PM   #1
vince_2x
LQ Newbie
 
Registered: Sep 2004
Location: Australia
Posts: 7

Rep: Reputation: 0
finding total used space by a user in a directory


Hi there, I am wondering why this syntax is not working as expected.. any help owuld be appreciated, thanks



for foo in `$AWK -F":" '{print $6}' $PASSWD` ; do
#Checking if i have the permission to read these directories
if [ -r $foo ] ; then
if [ "$foo" != "/" ] ; then

#getting username, home directory and User ID
HOME=`$GREP :${foo}: $PASSWD | $AWK -F":" '{print $6}'`
USER=`$GREP :${foo}: $PASSWD | $AWK -F":" '{print $1}'`
UID=`$GREP :${foo}: $PASSWD | $AWK -F":" '{print $3}'`

if [ $UID -gt 500 ] ; then
if [ $UID -lt 60000 ] ; then
HOMESPACE=0
VARSPACE=0
PRJSPACE=0

#Finding the amount of space use in the home for the user
HOMESPACE=`du -h -k -s $HOME | awk '{print $1}'`

#Finding amount of space use in /var
echo "Finding all files owned by $USER in /var...and adding their total space used "
find var/ -user $USER -exec du -k -s -h {} \; | awk '{user[$1]+=$2}; END{ for (i in user) { VARSPACE=expr '$VARSPACE'+ i }'

echo $VARSPACE
fi
fi
fi

fi
done


My problem is that the value of VARSPACE is always 0, it seems that awk cannot change the value of the variable VARSPACE... any idea or solution to do calculate the total use soace by a particular user in the var directory??? thanks
 
Old 09-21-2004, 06:49 AM   #2
320mb
Senior Member
 
Registered: Nov 2002
Location: pikes peak
Distribution: Slackware, LFS
Posts: 2,577

Rep: Reputation: 48
Code:
du -s * | sort -nr > $HOME/space_report.txt
try this...............
 
  


Reply



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



Similar Threads
Thread Thread Starter Forum Replies Last Post
Nmap help, total newblet from space. zarathaz Linux - Newbie 3 07-19-2005 11:49 PM
finding size of total files in a directory blackzone Linux - Newbie 3 01-07-2005 03:01 AM
Not enough space for root directory on a drive with 50g free space??? auoq Linux - Newbie 1 10-13-2004 12:44 PM
format only gives me less than total space ctrl-a Linux - Newbie 4 10-12-2004 04:15 PM
mdk 9.2 user directory using all the free space on partition? 1beb Linux - Newbie 5 11-21-2003 10:10 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 09:32 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration