You can actually create a HTML document using the shell script. If you are tired to see the output of your command in the terminal, you can redirect your output to the HTML document. This will allow you to see the output in the web browser like the website. I will assume, you know the basics of HTML. Even if you don’t, it’s very easy to learn. Find some good tutorials and get started.Now, let’s get started by writing a simple shell script with HTML tags in it.
echo "Output in a HTML Document"
This simple shell script called “test” will display the file called freshtutorial which I have already created in my home directory. Every HTML tags have to be quoted with echo. Redirect the
script to HTML document.
sh test >> test.html
Open the test.html and see the output. Instead of creating a output into the terminal itself, it redirects the output to a webpage.
cat << noEcho
<TITLE> Cool Bash trick </TITLE>
“noEcho” is called token in the above script named “display”. You can assign any token as you want besides the bash keywords. Redirect the script into a webpage issuing the following command:
sh display >> display.html
This all might seem confusion at the beginning. Once you get used to it, it feels amazing. It is a nice cool shell programming trick as well. If you have any confusion, feel free to ask questions as comment.