Display multiple words into a single td tag

awk 'BEGIN{print "<table>"}  {print "<tr>";
for ( i=1;i<NF;i++) print " <td>" $I "</td>";
print "</tr>"}

END{print " </table>"}' <file name >

Variable name is case sensitive:-

awk '
        BEGIN {
                print "<table>"
        }
        {
                print "<tr>"
                for ( i = 1; i <= NF; i++ )
                        print "<td>" $i "</td>"
                print "</tr>"
        }
        END {
                print "</table>"
        }
' 
1 Like

I want to display output of a select query into a Unix variable and create a html file with the values in the variable and display content in table format in the email body.
The above code is working correctly if and only if the query retrieves a single word data in the column, if the query returns
Let's say ABC Pqr into a single column the Pqr is printed on the next row I want ABC Pqr into one column .

Normally we write the processing of SQL statements in a server-side scripting language meant for the web, using "created for the web languages" like PHP or Javascript.

Also, depending on how you write your SQL select query, the results of the select query are generally in an array and so the script generally needs to process an array, not a simple string or text file.

However, if you are looking for a single element only from the SQL select query, the results of the SQL query are often still in an array, a single element array.

So, in the general case, you should write your script to process an array as the input to your script which is the output of the SQL query.

1 Like

There is no javascript or php allowed.

Redisplaying the problem statement :
Need to write a Unix shell script (bash)
To display active inactive sessions from oracle database in the body of the email. Along with long running queries if any

Because this is homework / school work?

This is a office work

Moderator comments were removed during original forum migration.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.