is there a way to add a td tag with sed?

example code

What I want to do is add an ending TD tag ( </td> )

sed 's/./&</td>/g'

Simple data:

<tr><td>listenhere<insert/tdtaghere><tr><td>listenhere<insert/tdtaghere><tr><td>listenhere<insert/tdtaghere>

Ending where? The end of a line? The end of a paragraph?

Please provide sample data as well.

Suppose you had a CSV file you wanted to be a table. Ignoring quotes and quoted commas for the moment (Access 2000 does, so why not me?), this would turn it into table guts:

sed '
  s/[^,]*/<TD>&<\/TD>/g
  s/,//g
  s/.*/<TR>&<\/TR>/
 '

Take every area of not comma and wrap it in td, dump the commas and wrap each line in tr.

1 Like

What about if I wanted to sed out every character except for the first character of a word?

OR

Take what you sed out and attach it to a variable so that you can call upon it later?

$parameter

sed s/^$parameter/./g

What about if I wanted to sed out every character except for the first character of a word?

 
  This works with 'old' regex (someone changed the meaning or \< and \> on us) and words of only letters:
 
    s/\<\([a-zA-Z]\)[a-zA-Z]*/\1/

Take what you sed out and attach it to a variable so that you can call upon it later?

 
  Env variables can hold a lot, often up to a meg total:
 
   export hold_table_guts=$( sed_script )

Did you say what language you were writing the web page in? I use ksh, but on my own server! PERL is traditional, and then came ASP, JSP and all the flood!