Computing.Net > Forums > Unix > [Script] Filesize checking - HELP!

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

[Script] Filesize checking - HELP!

Reply to Message Icon

Name: Sc0rpi0N
Date: April 12, 2005 at 05:39:38 Pacific
OS: OpenServer 5.0.6
CPU/Ram: Dual Xeon 2.4
Comment:

Hi everybody!

I'm trying to make a script that will do the following...

I want the script to be able to check the filesizes in a directory and if it is greater or equal to 1.5gb (1500000000) to send an e-mail to the administrator... How would I go about it?

So far I have the following, but it doesn't seem to be working... any ideas?

if [ `ls -al <directory>/* |awk '{ print $5 }'` -eq 1500000000 ]
then
echo "Yes!"
else
echo "No!"
fi

The "echo's" are for testing to see if the script works, if it does I can arrange to send an e-mail to the admin, thar's not a problem.

Thanks in advance!



Sponsored Link
Ads by Google

Response Number 1
Name: Sc0rpi0N
Date: April 12, 2005 at 05:40:21 Pacific
Reply:

I made a little typo, in the if statement it is not -eq but -ge, sorry, thanks.


0

Response Number 2
Name: David Perry
Date: April 12, 2005 at 09:12:24 Pacific
Reply:

man find

find $directory -size +15000000k -exec ls -l {} \; > find.out
if [ -s find.out ] ; then
cat find.out | mail -s "Search Results `date`" admin@domain.com
else
echo "NONE FOUND"
fi


0

Response Number 3
Name: Sc0rpi0N
Date: April 14, 2005 at 07:29:52 Pacific
Reply:

Thank you very much!

Works like a charm :)


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More


how to configure printcap... A script to share



Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Unix Forum Home


Sponsored links

Ads by Google


Results for: [Script] Filesize checking - HELP!

shell script to check for a file on www.computing.net/answers/unix/shell-script-to-check-for-a-file-on/3714.html

script to check a dynamic ip www.computing.net/answers/unix/script-to-check-a-dynamic-ip/6456.html

Need Help With KSH Script www.computing.net/answers/unix/need-help-with-ksh-script/6747.html