I want to replace instances of <span class='i'> </span> with <i> </i> because I decided I want to format my pages this way instead. So I have come up with this command:
perl -pe "s/<span +class *= *['\"]i['\"] *>(.*?)<\/span>/<i>\1<\/i>/g"
I could make it more elaborate but I really don’t think there are instances of weirdly formed tags like < / span> or anything so I’ll leave it at that. It does have a non greedy capture which is why I used perl -p rather than sed.
So this will output the correctly modified lines but I’m not sure about the best way to send multiple files through this command. What’s the best way to do it if I want all of pages/*.html to have the span class='i' tags fixed? Does bash provide some provision for doing this other than a for loop?
The following will iterate over all html files in
pages/and do an in-place edit with your perl script .