Lets say you had a web page and you wanted to change the css at certain times to show a new picture. Here’s some sed regexp’s to do it for ya.

In this example, I am picking a random image from a directory of approved images and switching out the old whatever.jpg with newstuff.jpg




heres the line i am going to be editing (actually the background of my site):

background-image: url(https://website.net/img/backs/whatever.jpg);

cd /var/www/img/backs/

set --




cd /var/www

mv style.css style.css.bak

sed "s/img\/backs\/.
/img\/backs\/$file);/" style.css.bak > style.css```

Very useful for changing the background of a site by just setting up a cron job to change it whenever you like.

Blog Logo

Mario Loria




Because gets old after a while.

Back to Overview