[prog] bash script

apeschel+linuxchix at uci.edu apeschel+linuxchix at uci.edu
Wed Aug 27 10:57:41 UTC 2008


Hello, 
This is my first time posting to the linux chix newsletters. Hopefully I
have everything in order. 

It looks like the problem is this line:
	total=`du -sh $srvr/$usr | awk '{ print $1 }'`

Specifically, $srvr/$usr.

Since $srvr/* expands out to the full path name for every file in $srvr,
there is no need for $srvr/ on that line. $usr is already set to the full
path name.

Try using this instead:
	total=`du -sh $usr | awk '{ print $1 }'`

If you're still uncertain, try adding an echo statement in there somewhere
to see if what you want to happen is actually happening:
	echo $srvr/$usr

-Aaron Peschel

-----Original Message-----
From: programming-bounces at linuxchix.org
[mailto:programming-bounces at linuxchix.org] On Behalf Of Wolf Rising
Sent: Monday, August 25, 2008 8:33 AM
To: Programming at linuxchix.org
Subject: [prog] bash script

I would like to have a script go thru several computers and check how much
space is being taken up by each user, preferably it would be displayed in
two
columns showing the user's name and space used in GB or MB descending from
most space used to least:

I was using:

for srvr in /usr/center/server1 /usr/center/server2 /usr/center/server3
/usr/center/server4
do
    for usr in $srvr/*
    do
        total=`du -sh $srvr/$usr | awk '{ print $1 }'`
        echo $usr: $total
    done
done

however it does not return the results displayed properly, could anyone
suggest
how to get the script to do so?

It takes quite a while to run as I believe there are several 100gbs to go
thru, if there is
a way to increase speed performance I would be interested in that as well.

Thanks!

<Programming at linuxchix.org>
_______________________________________________
Programming mailing list
Programming at linuxchix.org
http://mailman.linuxchix.org/mailman/listinfo/programming




More information about the Programming mailing list