Let's see if I get this..
Code:
#!/bin/bash
DIR="$1"
if [ $# -eq 0 ]; then
echo "$(basename $0) dir"
exit 1
fi
for f in $DIR/*
do
if [ ! -f $f.bakup ]; then
/bin/cp $f $f.backup
fi
out="/tmp/out.$$.tmp
cat $f | sed '/^$/d;s/^[ \t]*//;s/[ \t]*$//' > $out
/bin/mv $out $f
done
You mean .bakup then would be .php and/or .html etc.?
I'd like to apply this to all .css, .js, .htm*, .php* files.
I used to have this with perl, but I lost the script, it was something like;
Code:
#!/bin/sh
$ perl -pi -e 's|[old_string]|[new_string]|g' [file]
but I don't really remember much of it. It could run entirely RegExp based.