=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
UNIX GURU UNIVERSE
DICA UNIX
Dica Unix 2818 - 25 de agosto de 2007
http://www.ugu.com/sui/ugu/show?tip.today
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
CONVERTENDO TEXT2HTML
Precisa converter um arquivo texto para html ?
Crie um arquivo de nome txt2html com o seguinte conteúdo :
# Em alguns momentos a saída inicia com
# um header de html
BEGIN {print "<html>"
print "<head>"
# Use o nome do arquivo de entrada
# como o título
print "<title>" FILENAME "</title>"
print "</head>"
# O texto já é formatado
# portanto, use <pre>
print "<body><pre>"}
# linhas que consistem em um número
# de traços
# serão substituidos por <hr>
/^---*$/ {print "<hr align=\"left\" width=" length "0 size=1>"; next}
# linhas que consistem de um número de sinais iguais
# serão substituidas por <hr>
/^===*$/ {print "<hr align=\"left\" width=" length "0 size=3>"; next}
# maior que e menor que
# sinais serão substituidos por tags.
{gsub("<","\<") gsub(">","\>")
# Substitua as quebra de linha
# por algumas linhas em branco
gsub("^L","<br>\ <br>\ <br>\ <br>") print}
# No final do resultado ( saída ),
# finalmente, fechamos as targs
END {print "</pre></body>"}
Torne o arquivo executável (chmod a+x txt2html) e você finalmente está apto para converter os seus arquivos texto para o formato html.
txt2html something.txt > something.html
Esta dica foi generosamente remetida por : ugu@couprie.org
------------------------------------------------------------------------
Para assinar: http://www.ugu.com/sui/ugu/show?tip.subscribe
Para sair: http://www.ugu.com/sui/ugu/show?tip.unsubscribe
Para enviar uma dica: http://www.ugu.com/sui/ugu/show?tip.today
======================================
DECLARAÇÃO: TODAS AS DICAS DE UNIX SÃO PROPIEDADE DA UNIX GURU UNIVERSE
E NÃO SÃO PARA SER VENDIDAS, IMPRESSAS OU USADAS SEM O CONSENTIMENTO POR
ESCRITO DA UNIX GURU UNIVERSE. TODAS AS DICAS SÃO "USADAS POR SEU PROPIO RISCO".
UGU ADVERTE PARA TESTAR TODAS AS DICAS EM UM AMBIENTE QUE NÃO ESTEJA EM
PRODUÇÃO.
Unix Guru Universe - www.ugu.com - tips@ugu.com - Copyright 1994-2007
======================================