This blog post explains how to quickly generate a few junk HTML pages. I personally needed something like this when I was testing a few of my web app ideas. To start, ensure you’re using something similar to BASH version 4.4.12 (you check what you have using bash --version).

First, we’ll use a for loop to make a few empty files.

for page in index.html about.html contact.html; do touch $page; done

Then, we’ll use echo & tee to inject some a few simple HTML tags into each page.

echo -e "<html>\n<body>Hello world\n</body>\n</html>" | tee *.html

A cleaner method would be to hit [enter] immediately after the first " and then, book-end your command sentence with " | tee *.html.

echo -e "
<h1>Hello world!</h1>
</html> " | tee *.html

Finally, to append any additional content, use sed. Here, I’m telling sed to edit each HTML page in-place and start appending (/a) content after the line containing <h1>Hello world!</h1>.

sed -i "/<h1>Hello world!</h1>/a foo" *.html