Archive for December, 2007

beautiful shell script – rename files with paths – man find

December 21, 2007 5 comments

I’m in the process of converting a MCMS generated site over to php / unix environment and was suffering from the “default.htm” problem. So I needed to copy all the default.htm files to index.htm. Was sitting there playing with some shell scripting for a minute and then found this GREAT link: awesome one-liner:

for f in `find . -name '*replaceme.jpg'` ; do mv $f ${f/replaceme/withme}; done

Ok, so I had to see how this thing works… I’ve used bash for several years and never saw this ${f/x/y} syntax.. looking at the bash reference guide, it looks like “shell parameter expansion”. Very convenient.. if only I had read the manual sooner….


Excel macro to MySql code

December 12, 2007 2 comments

I had an idea for a little Excel macro today.  I needed to take a set of data from an excel sheet and insert into a MySQL database.  It would be great to have an excel add-in that could take the highlighted cells as input and generate an insert statement for each row, and of course doing a little magic of just quoting non-numerics.

  1. Select cells
  2. Hit add-in
  3. Enter table name


Categories: excel, tech