Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Recursively creates an index.php file in all subfolders that don't include an index.php file
shopt -s globstar
for i in **; do
if [ -d "$i" ]; then
# update this line to include directories to ignore
if [[ "${i##/*}" != *"node_modules"* && "${i##/*}" != *"bower_components"* ]]; then
if [ ! -f "${i##/*}/index.php" ]; then
printf "Creating index file in %s\n" "${i##/*}"
printf "<?php\n// Silence is golden." > ${i##/*}/index.php
fi
fi
fi
done;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.