So I created this little guy to help me out. Whenever run, he generates a date line in html that looks like this on a web page:

Last updated Wednesday December 15 2010

and updates a footer file I’ve called foot.tpl

___update.sh

```

!/bin/bash

change the Last updated part of foot.tpl

cd /var/www/

generate nice looking date command

DATE="$(date "+%A %B %e %Y")"

MYVAR="

Last updated"

END="

"

FINAL="$(echo $MYVAR $DATE $END)"

we are going to look for any line that has the word updated and replace that whole line with our new one now contained in the variable FINAL

sed "

/updated/ c\

$FINAL

" foot.tpl > footnew.tpl

mv footnew.tpl foot.tpl```

And thats it!  For me, the word “updated” only shows up once in my foot.tpl so the old line is completely removed and replaced with the new one.

Very useful.

Blog Logo

Mario Loria


Published

Image

./scriptthe.net

Because 127.0.0.1 gets old after a while.

Back to Overview