![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| How do I extract text only from html file without HTML tag | los111 | UNIX for Dummies Questions & Answers | 4 | 11-28-2007 04:40 AM |
| HTML message with attachment (text-file) | Felix2511 | UNIX for Dummies Questions & Answers | 2 | 09-12-2007 03:59 AM |
| html - text file question | frustrated1 | Shell Programming and Scripting | 5 | 09-21-2005 06:23 AM |
| Converting Text File into XML using Unix Shell Scripts | Laud12345 | Shell Programming and Scripting | 10 | 02-16-2005 01:35 PM |
| linking unix generated text file to html page | alexd | Shell Programming and Scripting | 1 | 11-13-2002 12:21 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
Converting a text file to HTML
Hi,
I need to convert a text file formatted like this ("tshark -z conv,ip" output) to HTML: Code:
=====================================================================================================
IPv4 Conversations
Filter:<No Filter>
| <- | | -> | | Total |
| Frames Bytes | | Frames Bytes | | Frames Bytes |
192.168.1.246 <-> 192.168.1.135 2 276 1 60 3 336
192.168.1.255 <-> 192.168.1.167 2 184 0 0 2 184
192.168.1.255 <-> 192.168.1.99 1 265 0 0 1 265
192.168.1.255 <-> 192.168.1.164 1 126 0 0 1 126
10.0.0.255 <-> 10.0.0.250 1 126 0 0 1 126
192.168.1.255 <-> 192.168.1.41 1 92 0 0 1 92
=====================================================================================================
Thank you! ![]() |
|
||||
|
Let me be more specific. I can display the data I need by doing:
Code:
awk '//{print $1,$3,$5,$7,$9}' file.txt |grep -v "|" |grep -v "Filter" |grep -v "IPv4" |grep -v "="
<TR><TD> in front of $1 </TD><TD> in front of $2, $3, $5, $7, $9 </TD></TR> at the end of each line (after $9) How would I go about doing that? Thank you! ![]() |
|
||||
|
Here's what I did and it actually works. It's very inefficient though:
Code:
awk '//{print $1,$3,$5,$7,$9}' file.txt |grep -v "|" |grep -v "Filter" |grep -v "=" |grep -v "IPv4" |sed 's/^/<TR><TD>/' |sed 's" "</TD><TD>"' |sed 's" "</TD><TD>"' |sed 's" "</TD><TD>"'|sed 's" "</TD><TD>"' |sed 's"$"</TD></TR>"g' >file.htm
Grazie! ![]() |
|
||||
|
This should work:
Code:
awk -v a="<TR><TD" -v b="</TD><TD>" -v c="</TD></TR>" 'BEGIN{print "<html><table>"}/^[0-9]/{print a$1b$3b$5b$7b$9c}END{print "</table></html>"}' file.txt > file.htm
Last edited by danmero; 10-29-2008 at 06:23 PM.. |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|