17 Jan 2009 philiph   » (Journeyer)

I'd like to share a bit of bash script that I wrote yesterday that I am both very proud of and very disturbed by:

DfLine=$(df -h /misc/backup | tail -1)
# convert DfLine into a bash array...
DfLine=(${DfLine// / })
echo -n ${DfLine[3]}
echo " free space remaining on /misc/backup"

So basically I did a perl split on whitespace and stuffed the results into an array. Actually I'm think that's a split on " *", not whitespace as I suspect it wouldn't work on tabs. I didn't test that though.

Also I think it should be possible to do the command substitution and the expansion of $DfLine in one go but all the $({$({${{ started to make my head hurt so I stopped there.

Inspiration from this unix.com page.

This is probably a pretty good indication that it's time to re-write the script in perl.

Latest blog entries     Older blog entries

New Advogato Features

New HTML Parser: The long-awaited libxml2 based HTML parser code is live. It needs further work but already handles most markup better than the original parser.

Keep up with the latest Advogato features by reading the Advogato status blog.

If you're a C programmer with some spare time, take a look at the mod_virgule project page and help us with one of the tasks on the ToDo list!