I have a bash script that looks like the following:
#!/bin/bash
FILES=public_html/*.php # */ stupid syntax highlighter!
for f in $FILES
do
echo "Processing $f file..."
# take action on each file.
done
Now I need it to go through all subdirectories in public_html
so it should run on:
/public_html/index.php
/public_html/forums/status.php
/public_html/really/deep/file/in/many/sub/dirs/here.php
What do I change FILES=public_html/*.php
to in order to do that?
Also I need to check to make sure that there is at least one file or else it prints
Processing *.php file...
FILES=$(find public_html -type f -name '*.php')
IMPORTANT: Note the single quotes around the *.php
to prevent shell expansion of the *
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With