Currently I am attempting to write a bash script that automagically formats ascii IM logs and appends it to a larger HTML file for my website. The current page can be seen here
(warning: may contain material, all in text of course, objectionable to those who don't realize it's so absurd as to be harmless)
Here is my code:
#adds newline to end of backup file
echo -e '\n' >> /goofyheadedpunk/logfile.backup
#appends file to be processed to backup
cat /home/blt/logfile >> /goofyheadedpunk/logfile.backup
#the sed takes an unformated ascii, and formats it to HTML
#this is then output to the variable TEXT
TEXT=$(sed -e 's/^[^:]*:/<font color="#a82f2f"><b>&<\/b><\/font>/g' /home/blt/logfile -e 's/<font color="#a82f2f"><b>goofyheadedpunk:<\/b><\/font>/<font color="#16569e"><b>goofyheadedpunk:<\/b><\/font>/g' -e 's/<font color="#a82f2f"><b> goofyheadedpunk:<\/b><\/font>/<font color="#16569e"><b>goofyheadedpunk:<\/b><\/font>/g' -e 's/$/<br>/' #-e 's/^<br>$/<\/p><p>/')
#broken, needs help
#in using double quotes to expand TEXT recieve error message
# "sed: -e expression #1, char 63: Unknown option to `s'"
sed "s/\<!--replace--\>/$TEXT/g" /goofyheadedpunk/misc/socialization.html
#upload socialization.html to server (after recent addition)
/bin/ftp -v << !
put /goofyheadedpunk/misc/socialization.html socialization.html
/home/blt/logfile is the file I drop unformated ascii text into while I'm chatting. What happens is that my friends and I will have a particularly absurd exchange and I'll copy directly from my gaim window into the aforementioned file. Each new entry is separated from the last by a newline.
/goofyheadedpunk/logfile.backup is, well, a backup of /home/blt/logfile that is made before each processing of /home/blt/logfile. /goofyheadedpunk/misc/socialization.html is the source on my local machine to the above mentioned page.
I apologize for the rather tortuous sed bit of my script. If you don't want to sift through it, all that does is format the ascii of /home/blt/logfile into HTML for the above linked webpage and then assigns it to TEXT. TEXT exists so that I could replace a comment in /goofyheadedpunk/misc/socialization.html with new, formated, input from /home/blt/logfile.
The difficulty I run into is that $TEXT won't expand without double quotes ( at least I think it is now ) but when I use double quotes I get this error
sed: -e expression #1, char 63: Unknown option to `s'
I've played with the quotes, trying combinations of single quotes and double quotes, but I can't get anything to work.
Anyone see what I'm doing wrong?