LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 09-08-2009, 04:09 AM   #1
Tekken
Member
 
Registered: Jun 2009
Posts: 48

Rep: Reputation: 15
Script to give the disk usage in GB for each user.


Hi,

I am trying to write a script which gives the disk usage report of every user in the server. I have wrote a code in such a way that it calculates the disk size of each user under /home and gives the output on the command line.
EX:
1GB user1
1GB user2
1GB user3
... .....
... .....
nGB usern

i am able to send this output via mail, but i want a script which can go thru each and every line, compare the size and list only the user-names who have data more than 1GB so that the same can sent thru the email. Can any one suggest me the code for the same.

Thanks...
 
Old 09-08-2009, 06:39 AM   #2
rizwanrafique
Member
 
Registered: Jul 2006
Distribution: Debian, Ubuntu, openSUSE, CentOS
Posts: 147

Rep: Reputation: 19
Run as root in /home:

Code:
du -h --max-depth=1 .
 
Old 09-08-2009, 07:00 AM   #3
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,578
Blog Entries: 31

Rep: Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208
Assuming the output from your first code is in input.txt in the current directory then something like
Code:
while read size user rest
do
    if [[ "${size#G*}" -gt 0 ]]; then
        echo "$user"
    fi
done < input.txt
This is not tested and is just to give you an idea of a technique to try.
 
  


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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Script for getting host information,disk usage and all details o/p should be in html kishorem666 Linux - Server 4 09-17-2008 08:30 AM
script to get 100% cpu/disk usage sidra Programming 9 09-19-2007 04:26 AM
Script to monitor disk usage of a particular folder ajeetraina Linux - Server 3 07-20-2007 03:34 AM
find disk usage per user on a filesystem kebabhead Linux - General 4 08-06-2004 05:07 PM
Restricting user disk usage ugenn Linux - General 1 05-13-2002 09:16 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 10:13 AM.

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