My question is how can I change one word in many txt files in one directory and multiple subdirectories in BASH? I did as below (check all similar topics) but it is still not working. changePhrase is a name of directory where the subdirectories and files are. Inside that files there is a string that I want to change. I have to make it with a for loop (it's a task). Where is my mistake? Thank you.
#!/bin/bash
for file in changePhrase; do
if [[ -f $file ]] && [[ -w $file ]]; then
sed -i -- 's/old/new/g' "$file"
fi
done