Skip to content

Instantly share code, notes, and snippets.

@colinmollenhour
Created June 30, 2010 22:42
Show Gist options
  • Star 6 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save colinmollenhour/459311 to your computer and use it in GitHub Desktop.
Save colinmollenhour/459311 to your computer and use it in GitHub Desktop.
.htaccess combiner
#!/bin/bash
# Author: Colin Mollenhour
#
# Usage: Run from the webroot, .htaccess-combined will be created.
dest='.htaccess-combined'
pwd=`pwd`
echo -n "" > $dest
while read -r file; do
loc=`dirname $file`
if [[ "$loc" =~ '^\./downloader/pearlib/\w+' ]]; then continue; fi
if [[ "$loc" = "." ]]; then
dir=$pwd
else
dir="$pwd/${loc#*/}"
fi
echo "<Directory $dir >" >> $dest
cat $file | sed 's/^/ /' | awk 1 >> $dest
echo -e "</Directory>\n" >> $dest
done < <(find -L . -name \.htaccess -type f | awk '{ print length, $0 }' | sort -n | awk '{$1=""; print $0}')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment