I have over 500 site and i want to replace a specific word in all of them with random words from a text file.
Folders structure
www
- site1
- - idex.html
- site2
- - index.html
-site3
- - index.html
Word name: Dashemd
Txt file content one world per line, like this:
Hemd.txt:
Blue
Red
Pink
Green
More …
So i need replace word dashemd
in index.html of all folders with list of words in hemd.txt
file randomly.
Could you please help me?
I tried to replace with static word but i couldn’t do this with random words from txt file
find ./ -type f -exec sed -i -e 's/dashemd/newworld/g' {} \;
CodePudding user response:
Like this:
find ./ -type f -name '*.html' -exec bash -c '
word=$(shuf -n1 Hemd.txt)
sed -i -e "s/dashemd/$word/g" "$1"
' bash {} \;