Paintings from Sunset Series by Spence Munsinger, Color Field + Blank White Canvas + Realism + Contemporary Abstract Art, original paintings for sale

“Every child is an artist. The problem is how to remain an artist once he grows up.”
― Pablo Picasso

sed and awk (I love UNIX…) (technical)

Long term website design… I found I want to be able to add more painting pages and more photograph pages, and to continue to add the new stuff first…

The original design had pages numbered 1, 2, 3, 4, 5, 1 being the newest stuff, 5 being the oldest. Adding a new page meant renumbering all of that, and all of the pages throughout the site that link to it – also changing searched pages names over time, which screws up linking into the site.

I reversed it. The oldest page is “001”. Newest is the highest number. Adding a page means adding say an “008” page, linking the main page to that, and leaving the rest alone.

Changing the pages, about 70 of the individual pages – ahhh. That’s where UNIX tools come in very very handy. Here’s the command that changed one set of links from the old page to the new:

for i in ` grep photographs_5.html * | awk -F : ‘{ print $1 }’`
do
echo $i
sed ‘s/photographs_5.html/photographs_001.html/g’ < $i > $i.1
mv ${i}.1 ${i}
done

This loops through and finds any files with the string “photographs_5.html”
echos out each file
changes (using the sed command, standard UNIX tool…) from photographs_5.html to photographs_001.html, creating a new file named [file].1,
then replacing the original file by moving (mv) the [file].1 file over on top of the [file].

I love UNIX.

— spence

artist@spencemunsinger.com
spencemunsinger.com

Speak Your Mind

*