LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   bash script for listing all users with emails greater than 100mb (https://www.linuxquestions.org/questions/linux-newbie-8/bash-script-for-listing-all-users-with-emails-greater-than-100mb-752465/)

evil_empire 09-03-2009 01:27 PM

bash script for listing all users with emails greater than 100mb
 
Hi,
Help me with a bash script to get a list of all users on a server with more than 100MB of mail. (Mail is kept in /home/username/Mail/ for each user.)

I've never written a script before.

Thanks,

MensaWater 09-03-2009 01:42 PM

find /home -name Mail -a -size +100M |awk -F/ '{print $3}'

The above used the find command.

It searches under /home for any file with the name "Mail" that is 100 MB or greater in size.

This is then piped into the awk command. The options there set the field delimiter to "/" (intead of white space) then prints the 3rd field which would be the user's home directory which typically is the same as the user's login ID.

type "man find" for more detail on find command.

type "man awk" for more detail on awk command.

chrism01 09-03-2009 06:18 PM

You'll want to bookmark & read these:
http://rute.2038bug.com/index.html.gz
http://tldp.org/LDP/Bash-Beginners-G...tml/index.html

Possibly these as well
http://www.tldp.org/LDP/abs/html/
http://www.grymoire.com/Unix/ (specifically awk & sed)

evil_empire 09-04-2009 12:27 PM

Thank you very much jlightner.
And thanks to chrism01 too.


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