outputting a text file in html


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting outputting a text file in html
# 1  
Old 07-24-2009
outputting a text file in html

is there anyway i can paste/cat a text file into a html paragraph <p>
function html_header

{
cat <<END
<html>
<head><title>${1}</title></head>
<body>
<p>
${2}
</p>
END
}

function html_footer
{
cat <<END
</body>
</html>
END
}

Last edited by magnia; 07-24-2009 at 10:33 AM..
# 2  
Old 07-24-2009
replace
Code:
<p>
${2}
</p>

with
<p>
Code:
$(cat $2)
</p>

# 3  
Old 07-24-2009
Quote:
Originally Posted by magnia
is there anyway i can paste/cat a text file into a html paragraph <p>
function html_header
Code:
{
    cat <<END
<html>
  <head><title>${1}</title></head>
  <body>
    <p>
        ${2}
    </p>
END
}

function html_footer
{
  cat <<END
  </body>
</html>
END
}


Code:
filename="whatever"
htmlfile=whatever.html
header='<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
         "http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
  <head>
    <title></title>
  </head>
  <body>
    <p>
'
footer='
    </p>
  </body>
</html>'

{
 printf "%s\n" "$header"
 cat "$filename"
 printf "%s\n" "$footer"
} > "$htmlfile"

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Create html <ui> <li> by parsing text file

Hi you all, this is my first post in this forum. I'm italian (please forgive me) :-) so my english will fail to be correct... Anyway, let's get straight to the point! I have a text file like this: ,,,, Disney: 00961-002,,,, ,Pippo: 00531-002,,, ,,Pluto: 00238-002,, ... (5 Replies)
Discussion started by: alcresio
5 Replies

2. UNIX for Beginners Questions & Answers

Converting text file to html page

Hello Everyone, I have the following text file with the each field separated by newline Text file P file1-en-us_US-20170718T150157Z.json Wed 19 Jul 2017 06:10:13 AM EDT P file2-en-us_US-20170718T160150Z.json Wed 19 Jul 2017 06:10:13 AM EDT P file3-en-us_US-20170718T163218Z.json Wed... (9 Replies)
Discussion started by: nextStep
9 Replies

3. Shell Programming and Scripting

Format text file to html

Hi Experts, Anybody out there figure out on how to achieve in shell scripts or tools. I have done googling to find solutions but no luck. I have thousands of .txt files to batch process, please see the below sample text content after -------- start here --------. What I want to achieve is to... (10 Replies)
Discussion started by: lxdorney
10 Replies

4. Shell Programming and Scripting

HTML Conversion of text file

Hi, I have following text file. I want to convert it into the below HTML format. Kindly help. Input Text File Header 1 ======= Name:*** Age:*** Address:*** Work Phone:*** Email:*** Mobile:*** Country:*** City:*** Pincode:*** some text here **** (10 Replies)
Discussion started by: ctrld
10 Replies

5. Shell Programming and Scripting

Conversion of a text file to html

hi i hav a file called focus. which is the output file. i want to convert this file to html file and mail it. help with code and explanatio. i am basic in unix (7 Replies)
Discussion started by: wasim999
7 Replies

6. Shell Programming and Scripting

trouble with outputting html to check vmfs volumes

Hi - I found a script on the web to check vmfs volumes on ESX servers and create an html file for the output. Sometimes the script works fine, but sometimes it seems to break at the "vdf -h -P" line. More often than not, when I run it myself it works - but when run from chron it usually fails. ... (2 Replies)
Discussion started by: kpowell10
2 Replies

7. Shell Programming and Scripting

Align Text within <p> Tags in a HTML file.

Hi All !!! I have an HTML file whose contents are as below: <html> <body> <title>This is a test file</title> <p>PLEASE ALIGN ME IN ONE LINE. TEXT....</p> <h2>This is a Test file</h2> <p>PLEASE ALIGN ME IN ONE LINE. TEXT....</p> </body> </html> (2 Replies)
Discussion started by: parshant_bvcoe
2 Replies

8. Shell Programming and Scripting

Converting a text file to HTML

Hi, I need to convert a text file formatted like this ("tshark -z conv,ip" output) to HTML: ===================================================================================================== IPv4 Conversations Filter:<No Filter> | <- ... (4 Replies)
Discussion started by: ph0enix
4 Replies

9. UNIX for Dummies Questions & Answers

How do I extract text only from html file without HTML tag

I have a html file called myfile. If I simply put "cat myfile.html" in UNIX, it shows all the html tags like <a href=r/26><img src="http://www>. But I want to extract only text part. Same problem happens in "type" command in MS-DOS. I know you can do it by opening it in Internet Explorer,... (4 Replies)
Discussion started by: los111
4 Replies

10. Shell Programming and Scripting

html - text file question

Hi - not sure if this is the correct forum but maybe you can help all the same. I have an ascii file on my server that I log events to.. I have samba and apache running on this server also - although I am not currently using them and have just started them up. They both appear fine so far. I... (5 Replies)
Discussion started by: frustrated1
5 Replies
Login or Register to Ask a Question