Extract both contents from a html file and do printing

Hi there,

Print IP Address:

 grep 'HostID     :' 10.244.9.124\ nessus.html | awk -F '<br>' '{print $12}' | tr -s ' ' | awk -F ':' '{print "<tr><td>" $2 "</td><td>"}' 

Print Respective Ports:

 grep 'classsubsection\|./tcp\|./udp' 10.244.9.124\ nessus.html | grep -v 'h2.classsubsection {\|Port\|0/'  | sed 's/<[^>]*>//g' 

Print IP Address:

10.244.9.124

Print Respective Ports:

25/tcp       53/tcp     53/udp     88/tcp     123/udp   135/tcp     137/udp   139/tcp     389/tcp       445/tcp                 464/tcp   593/tcp     636/tcp     1025/tcp     1027/tcp       1044/tcp     1058/tcp     1063/tcp     1067/tcp     1115/tcp     2301/tcp       2381/tcp                                                   3181/tcp   3268/tcp       3269/tcp     3389/tcp 

I would like to print out in this format say if I would have multiple files to get the IP Addresses and its Ports

<table border='1'>
<tr><td>10.244.9.124</td><td>25/tcp</br>53/tcp</br>53/udp</br>88/tcp</td></tr>
<tr><td>10.244.9.125</td><td>53/tcp</br>53/udp</br>88/tcp</td></tr>
.........................................
</table>

Another seperate issue is how to search for ip address in the html file instead of using

  grep 'HostID     :'

Without a decent (but maybe abbreviated) input sample (including file nomenclature) your spec is difficult to understand. Please post sth. to work upon.

Hi there,

Actually it is fixed already.

echo "<table border = '1'>"
for file in *.html
do
    grep 'HostID     :' $file | awk -F '<br>' '{print $12}' | tr -s ' ' | awk -F ':' '{print "<tr><td>" $2 "</td><td>"}' 
    grep 'classsubsection\|./tcp\|./udp' $file | grep -v 'h2.classsubsection {\|Port\|0/' | sed 's/<[^>]*>//g' | grep -v '^$' | awk '{print $0"<br/>"}' 
    echo "</td></tr>"
done
echo "</table>"

However I am trying to iterate through the files with space.
10.244.9.124 nessus.html

grep: 10.244.9.124: No such file or directory
grep: nessus.html: No such file or directory

Try double quoting the file name variable.

Constructing an organ (pipe next to pipe) might not be the best solution.