zjm1126
zjm1126

Reputation: 35680

how to use sed to replace text in subfolders

i use this code to replace some text in an HTML file:

sed -i 's/tttt/new-word/g' /home/zjm1126/*.html

This doesn't search for files in subfolders, though. How do I apply this command to subfolders?

Upvotes: 6

Views: 4345

Answers (2)

Rob
Rob

Reputation: 1255

Can you try somthing like

for z in `find /home/zjm1126/ -type f -name "*.html"`; do
sed -e 's/tttt/new-word/g' $z>temp;
done

Upvotes: 1

sehe
sehe

Reputation: 393934

find /home/zjm1126/ -name '*.html' -print0 | xargs -0 sed -i 's/tttt/new-word/g'

Upvotes: 8

Related Questions