Created
August 26, 2015 19:12
-
-
Save franklinbr/e4fbb5b674d5f798c6fe to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
if [ $# -gt 0 ] | |
then | |
arquivo="$1.html" | |
cat /dev/null > ${arquivo} | |
echo "<html>" >> ${arquivo} | |
echo "<head>" >> ${arquivo} | |
echo "<meta charset=\"UTF-8\">" >> ${arquivo} | |
echo "<style>" >> ${arquivo} | |
echo "table { padding: 0px 0px 0px 0px; margin: 10px; border-collapse: collapse; }" >> ${arquivo} | |
echo "tr { padding: 0px 0px 0px 0px; margin: 0px 0px 0px 0px; }" >> ${arquivo} | |
echo "td { border: 1px solid #aeaeae; padding: 5px; margin: 0px 0px 0px 0px; }" >> ${arquivo} | |
echo "tr:nth-child(even) { background-color: #dadada; }" >> ${arquivo} | |
echo "tr:first-child{ font-weight: bold; }" >> ${arquivo} | |
echo "</style>" >> ${arquivo} | |
echo "</head>" >> ${arquivo} | |
echo "<body>" >> ${arquivo} | |
echo "<table>" >> ${arquivo} | |
if [ $# -gt 0 ] | |
then | |
cat $1 | sed '/^$/d' | sed '/---/d' | sed '/registro/d' | sed 's/|/<\/td><td>/g' | sed 's/^/<tr><td>/g' | sed 's/$/<\/td><\/tr>/g' >> ${arquivo} | |
else | |
echo "sem argumento" | |
fi | |
echo "</table>" >> ${arquivo} | |
echo "</body>" >> ${arquivo} | |
echo "</html>" >> ${arquivo} | |
else | |
echo "Entre com o nome da variavel. Ex: ./convert2.html.sh relatorio.txt - txt formato saida do postgresql" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment