Создание файла .html из logfileHtml

Программисты Html
Anonymous
Создание файла .html из logfile

Сообщение Anonymous »

Мне нужен скрипт, который преобразует файлы журнала в легко просмотренные файлы .html, доступный «Любой».#!/bin/bash

## The purpose of this script is to create .html files from log files, with the ability to optionally GREP for certain strings

if [ "$2" == "" ];
then
echo "Usage : $0 [Source Log file] [Output HTML file] [String to grep (if applicable)]"
exit 255
fi;

LOGFILE=$1
OUTPUTFILE=$2
GREPSTRING=$3

if [ "$3" == "" ];
then
echo "Cat'ing $LOGFILE to $OUTPUTFILE"
LOGCONTENTS=`cat $LOGFILE`

else
echo "Grep'ing for $GREPSTRING in $LOGFILE"
LOGCONTENTS=`grep --color $GREPSTRING $LOGFILE | sed -e "s/^.*$/&1\n/"`
fi;

# Below is the html heading which will be appended to the final .html file
HEADING="Log output for: $LOGFILE"

# Below is the end of the html file
END=""

# Below all the prepared variables are stitched together to the OUTPUT/LOG FILE
echo $HEADING > $OUTPUTFILE
echo $LOGCONTENTS >> $OUTPUTFILE
echo $END >> $OUTPUTFILE

# For debugging, enable the lines below
echo $LOGCONTENTS
echo "Done preparing $OUTPUTFILE"
< /code>

Моя проблема заключается в том, что выход, независимо от того, сколько я играю с Cat, Grep, SED и т. Д., Не сохраняет разрывы линии. Для выходного файла важно более или менее похожим на обычный хвост или кот.

Подробнее здесь: https://stackoverflow.com/questions/189 ... om-logfile

Вернуться в «Html»