This question already has an answer here:
- Find and replace with sed in directory and sub directories 6 answers
My qeustion is how in BASH I can change one word in many txt files in one directory and few subdirectories? 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 is a string that I want to change. I have to make it with a for loop (it's a task). Where is 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