Convert your text file to html in Linux by Command line.
text file to html.
Create a file named txt2html
with the following contents
# Always start the output with
#an html header
BEGIN {print “<html>”
print “<head>”
# use the name of the inputfile
# as title
print “<title>” FILENAME “</title>”
print “</head>”
# The text is formatted
# already, so use <pre>
print “<body><pre>”}
# lines consisting of a number
# of dashes (more than 1) are
# replaced by a <hr>
/^—*$/ {print “<hr align=\”left\” width=” length “0 size=1>”; next}
# lines consisting of a number of equalsigns are replaced
# by a thick <hr>
/^===*$/ {print “<hr align=\”left\” width=” length “0 size=3>”; next}
# less than and greater than
# sign must me replaced by tags.
{gsub(“<“,”\<”)
gsub(“>”,”\>”)
# Replace form feeds by a
# couple of empty lines
gsub(“^L”,”<br>\ <br>\&
print}
# At the end of the output,
# we must add some closing tags.
END {print “</pre></body>”}
Make this executable
(chmod a+x txt2html) and you’re
ready to start converting your test files.
txt2html something.txt > something.html
Convert Text to Html
Related posts
- Multi IP Ping Host Table March 27, 2018
Leave a Reply Cancel Reply
Latest Posts
- Modifies files date and times May 4, 2018
- Track Your Linux Login & Logout April 12, 2018
- Linux Tasks Alert April 12, 2018