I have folder with multiple html files and I'd like to run hxnormalize on all of them and write the results back into the files.

I already tried hxnormalize -e *.html and cat *.html | hxnormalize -e > *.html

  • Please look up the for loop in your shell's man page. Do you know what shell you are using? – Anthon Sep 28 '17 at 9:39
  • You may have clobbered one or more of your HTML files -- double-check the last one. – Jeff Schaller Sep 28 '17 at 9:46
  • it's bash. how would a simple example for a loop that selects all html files look like? And what I still havn't figured out, how do I write the results back into the original files? – user430 Sep 28 '17 at 9:55
  • @JeffSchaller I'm sorry, I don't know what "clobbered" means, but the second command definitely doesn't work, I get "bash: *.html: ambiguous redirect" error – user430 Sep 28 '17 at 9:58

according to man page, hxnormalize work on a single file.


 for x in *.html
    hxnormalize -e "$x" > foo
    mv -f foo "$x"

you can remove quote if no funny name.

you can single line

for x in *.html ; do hxnormalize -e "$x" > foo ; mv -f foo "$x" ; done

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.