I have a script which at one point does the following:
for src in $(find -H "$ROOT_DIR" -maxdepth 5 -name '*.test' -not -path '*.git*')
do
fixed_filename=$(echo "$(basename "${src%.*}")" | sed 's/-test//')
Basically, I have files called thing-test.js.test
When looping through I'd like to end up with the filename being thing.js
Eventually then I'll create the full path to the file using path="$ROOT_DIR"/"$fixed_filename"
The above seems to work, but it's definitely not correct - I'm an avid user of shellcheck and it tells me there's a useless echo (I agree) and to attempt ${variable//search/replace} if possible.
Would appreciate some help on cleaning up the above.
Edit:
The basic gist of what I'm trying to do is:
I'm trying to recursively search through every file in a directory following a particular file name pattern e.g. file-test.js.test and inside of these files are placeholder variables e.g. REPLACEME I want to find all these files, and one-by-one replace REPLACEME with a user supplied string from a read call inside of the bash script, and while I'm there I'd like to change the filename to file.js e.g. remove -test and .test