[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[shell-script] Re: Criar tabela html
From: |
mop |
Subject: |
[shell-script] Re: Criar tabela html |
Date: |
Sun, 28 Oct 2007 14:33:17 -0200 |
Tentei rodar o script, mas o que é $1?
Tentei faze-lo a saída do ls -C, mas parece que não é isso.
OFF
Você falou em links, não vi link nenhum.
Como estava difícil rabisquei algo (sem links), apenas formatação.
Se precisar link terá de tratar por célula (arq/dir).
Já pensou em fazer com <PRE> e fonte de largura fixa?
/OFF
Espero que te sirva de algo.
É só rodar no diretorio desejado.
Para gerar arquivo:
script >/tmp/z.htm
COL=80
echo -n "<html><table border=4>"
/bin/ls -C|while read -n $COL l;do
[ "${c:10:1}" = 7 ]&&c=' bgcolor=#88CCFF'||c=' bgcolor=#77FFCC'
l=" `echo -n $l`"
l="<tr$c>${l// /</td><td>}</td></tr>"
echo -n "${l/<tr><\/td>/<tr>}"
done
echo -n "</table></html>"
------------------------------------------------------------------
>> A minha questao é Shell Script mesmo.. e atendendo seu pedido,
>mostro o script que fiz, porem como falei a cima.. ele cria apenas um
>link por linha e eu quero he que fique igual ao resultado do comando
>'ls -C'. Se alguem poder ajudar, agradeço.
>
>Este é o scritp :
>
>#!/bin/bash
>#cria tabela htm
>
>n=$1
>
>if [ $# -ne 1 ]
>then
>echo
>echo "Digite o nome da pagina"
>echo
>exit 1
>fi
>
>i=0
>while read line
>do
>i=$((i+1))
>if [ "$((i%2))" == "0" ]
>then
>echo "</td></tr><tr bgcolor=#778899><td>"
>else
>echo "</td></tr><tr><td>"
>fi
>echo $line
>
>done < $n > ${n}b
>
>#insere cabeçalho html no index.html
>echo "<html> <body>" > index.html
>echo "<table width=100% border=0 cellpadding=1 cellspacing=0>" >>
>index.html
>#pasando as tags da tabela para o index
>cat ${n}b >> index.html
># fechando as tags
>echo "</table></body></html>" >> index.html
>echo
>echo "Index pronto"
- [shell-script] Re: Criar tabela html,
mop <=