When I run my bash script(given below) the files are not changed. The replacement does not happen for some reason. I am running the command as sudo, and the html folder has permssions 775 with the owner being my user.
#!/bin/bash
# Get the directory to search from the user
#read -p 'Enter the directory to search: ' directory
directory='/var/www/html/'
# Get the text to search for
search_text='Gavin'
# Get the replacement text
replace_text='dingus'
find "$directory" -type f -exec sed -i 's/$search_text/$replace_text/g' {} ;
# Print confirmation message
echo "Replaced '$search_text' with '$replace_text' in all files within '$directory'"
I have tried running the command as sudo and as my user.
I am expecting the file to change any occurrences of "Gavin" with "dingus" globally in all files in the /var/www/html directory.