Monday, November 20, 2017

get the size of folder contents

du -sh 


15M big_folder
0 dead.letter
4.0K some_file
4.0K some_other_file

Wednesday, November 15, 2017

challenges with grails unique: true

Grails does not evaluate a unique constraint at GORM level but at the database level

    static constraints = {
        property unique: true

This means that you would not get a grails.validation.ValidationException but a org.springframework.dao.DataIntegrityViolationException.

This means that


would not capture a duplicate "property"

Wednesday, August 16, 2017

Sometimes cron runs twice

I suspected cron was running twice. I confirmed by checking the system logs

grep CRON /var/log/syslog

Then I killed cron and restarted it

sudo /etc/init.d/cron stop
sudo /etc/init.d/cron start

Wednesday, September 28, 2016

Sending mail in unix with attachment

You would need to install sharutils

sudo apt-get install sharutils

Then run this

uuencode <path_to_file> <name_to_give_attachment> | mail -s "Subject"

Also see

Sunday, April 17, 2016

Sorting by type first then alphabetically

The script below ensures that items are sorted by type first then by alphabetical order.