So here is something that is very helpful. Jason walked me through one particular case that I needed and I thought I’d share it with everyone (including my future self).
Problem: The specific problem was that I needed to change the sytax of SSI when moving a client from Windows to Linux (i.e. IIS to Apache httpd).
On IIS the SSI tag is <!--#include file="..." -->
and on httpd it is <!--#include virtual="..." -->
So all that needs to happen is change “file” to “virtual”.
So what we want is to do s/<!--#include file=/<!--#include virtual=/g for each file.
Plan: We will use sed on each file we want to edit. We will use find will get us all the files we need.
Details: Create a script to that handles each file. I called mine /tmp/ssi-fix.sh. The file will contain
cat "$1" | sed 's/<!--#include file=/<!--#include virtual=/g' >/tmp/ssi-fix.tmp
mv /tmp/ssi-fix.tmp $1
$1 is the name of the file from the command line. We run sed against the file and output a temporary file and then move the temporary file over the original.
Once that is ready you can run this at the command line at the root of the tree you want to modify:
find . -name \*htm -exec sh /tmp/ssi-fix.sh \{\} \;
So in something closer to English … find all file whose name ends with htm in this directory (.) and lower and execute the shell script we wrote passing in the name of the file. The \{\} nonsense is the file name from find and the \; indicates the end of the statement to execute.


