Search all hidden .htaccess files inside a folder and run a terminal command

automatorfilesystemterminal

Searching for the issue, I found this Q&A:
How can I show only an .htaccess file in the Finder?

[…] you could create a symlink to the file in its directory, omitting the dot in the name:

  1. open Terminal, cd into your folder
  2. ln -s $PWD/.htaccess $PWD/htaccess

Is there some kind of terminal batch to search for all .htaccess files inside a folder (i.e.: /public_html) and apply the symlink?

Or would it be a combination of Automator and Terminal?

Best Answer

Change to the initial directory (public_html in the question) and run

find . -name '.htaccess' -print | while read f; do
    ln -s "$PWD/$f" "$PWD/${f//.htaccess}htaccess"
done

PS: I did some rudimentary testing but please make a backup before you run it anyway.