Your Ad Here

Sabtu, 04 Agustus 2012

Unix Tip: CONVERT TEXT2HTML

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

UNIX GURU UNIVERSE
UNIX HOT TIP

Unix Tip 3465 - August 4, 2012

http://www.ugu.com/sui/ugu/show?tip.today

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=


CONVERT TEXT2HTML

Ever felt the need to convert a
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("<","\&lt;")
gsub(">","\&gt;")

# Replace form feeds by a
# couple of empty lines

gsub("^L","<br>\&nbsp;<br>\&nbsp;<br>\&nbsp;<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


This tip generously supported by: ugu@couprie.org


--------------------------------------------------------------------------
To Subscribe: http://www.ugu.com/sui/ugu/show?tip.subscribe
To Unsubscribe: http://www.ugu.com/sui/ugu/show?tip.unsubscribe
To Submit A Tip: http://www.ugu.com/sui/ugu/show?tip.today

==========================================================================
DISCLAIMER: All UNIX HOT TIPS ARE OWNED BY THE UNIX GURU UNIVERSE AND ARE
NOT TO BE SOLD, PRINTED OR USED WITHOUT THE WRITTEN CONSENT OF THE UNIX
GURU UNIVERSE. ALL TIPS ARE "USE AT YOUR OWN RISK". UGU ADVISES THAT
ALL TIPS BE TESTED IN A NON-PRODUCTION DEVELOPMENT ENVIRONMENT FIRST.

Unix Guru Universe - www.ugu.com - tips@ugu.com - Copyright 1994-2001
==========================================================================

Tidak ada komentar:

Posting Komentar

Your Ad Here
Free Automatic Backlink Free Auto Backlink Free Auto Backlink Free Auto Backlink Free Auto Backlink Free Auto Backlink Free Auto Backlink Free Auto Backlink Free Auto Backlink Free Auto Backlink