My HTML code has the following line.
<TH>column1</TH><TH>column2</TH><TH>column3</TH>
Can I use sed tool to replace the column1 with “Name”, column2 with “Surname” …
<TH>Name</TH><TH>Surname</TH><TH>City</TH>
I have the list of the columns in a echo statement of my shell script.
echo 'Name, Surname, City'
These 3 values needs to be replaced in the respective columns in the HTML code. The number of columns might change.
Can you change the input format of the new column names, or are you stuck with the
echo. And does the table header line appear once per html file, or multiple times?For your current situation, this would work:
Output:
Note that things will go horribly wrong when your input html has a different form (additional or missing newlines). If you want to do anything more advanced you should use a proper SGML parser instead of
awkorsed.