A little bit of a programming (scripting) help

wattie

Verified User
Joined
May 31, 2008
Messages
1,206
Location
Bulgaria
On my server some people do have .htaccess files in their public_html folders, others don't. I wish to generate a list of all users who do NOT have .htaccess file there.

So I am looking for list of all <username> in /home/<username>/domains/<domain>/public_html/ which do NOT have /home/<username>/domains/<domain>/public_html/.htaccess file...

Any bash/sh guru out there who wish to give me a hand with this? Currently I am doing it the hard way... and yeah, I don't like it :) My sh script efforts to do the above are a total failure so far.
 
something like this should work (I haven't tested it, but there isn't any reason it shouldn't work):
Code:
#!/bin/sh
for username in `ls -1 /home/*`
do
   for domainnm in `ls -1 /home/$username/domains/*`
   do
      if [ ! -f /home/$username/domains/$domainnm/public_html/.htaccess ]
      then
         echo /home/$username/domains/$domainnm/public_html/.htaccess does not exist
      fi
   done
done
 
Used the idea and alsmost did it (actually did something working):

#!/bin/sh
for username in `ls -d /home/*`
do
for domainnm in `ls -d $username/domains/*`
do
if [ ! -f $domainnm/public_html/.htaccess ]
then
echo $username
fi
done
done

Thank you!
 
Back
Top