I'm trying to write a one-liner to convert html entities present in some files (all html with UTF-8 encoding)
I've tried
recode HTML_4.0 file.htm
but that also converts non-ASCII characters (it breaks the UTF-8 characters)
In StackOverflow I found something that works for one file:
php -r '$f=@fopen("file.htm", "r");echo html_entity_decode(fread($f, 20000));fclose($f);'
but when I try to make it for multiple files with
for fi in *.htm; do php -r '$f=@fopen("$fi", "r");echo html_entity_decode(fread($f, 20000));fclose($f);';done
I know the problem here is how to "escape" $fi (bash variable) so PHP doesn't read it as a PHP variable. Any advice?