Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a bash shell script that I use to upload a set of HTML files to a web server. The script makes various changes to the code before it uploads it.

One thing I'd like to do is strip the HTML code of comments and excess white space.

Is there a command I can use to do that within the bash script?

share|improve this question
In case you don't get the answer here because it isn't strictly Ubuntu-related, you may consider asking over at – user25656 Mar 29 '12 at 7:41
up vote 1 down vote accepted

Take a look at tidy. It might help you achieve the results you'd like to have. Version 20091223cvs-1 is available from the repositories.

Tidy is a:

HTML syntax checker and reformatter Corrects markup in a way compliant with the latest standards, and optimal for the popular browsers. [...]


share|improve this answer
This is a viable solution so I marked it correct, but actually, I ended up using HTMLcompressor instead: . Answer was found on Stack Overflow: – Questioner Apr 8 '12 at 6:55
Thank you for following through! That tool will probably better suit to your needs. Also the compressor's page is a very interesting read. – lgarzo Apr 8 '12 at 19:35

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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