Skip to content

Instantly share code, notes, and snippets.

@cameronjonesweb
Last active October 7, 2020 23:40
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cameronjonesweb/11acf7a1c5ea923a6d6ec7f23aac87c9 to your computer and use it in GitHub Desktop.
Save cameronjonesweb/11acf7a1c5ea923a6d6ec7f23aac87c9 to your computer and use it in GitHub Desktop.
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