2008-02-11

Sed: add space into an regular expression

I am writing a script that compresses web files in order to reduce the size of a site and load on the server. After stripping out leading and trailing spaces I remove newlines and this causes problem with PHP files, since I get something like this:


<?php...

where ... represents some PHP code. This is not valid. The following is needed - note the space before ...:


<?php ...

I am writing a script in Bash shell using sed for string conversions. I am sure Perl, Python or other scripting languages would be a better choice, but I am not familiar with them - even with sed I only scratch the surface. I did not know how to insert a space into an regex with sed, so I came up with the following solution:



sed \

-e "s/<?php[^ ]/jabudabu&/g" \

-e "s/jabudabu<?php/<?php\ /g" \

-e "s/<?[^(php) ]/jabudabu&/g" \

-e "s/jabudabu<?/<?\ /g"

2008-02-04

cron-apt

Dobra zadeva, če moraš skrbeti za več računalnikov in težko spremljaš, kje moraš kaj posodobiti.

http://www.debuntu.org/how-to-email-notification-upon-available-package-updates-with-cron-apt