use sed or awk (or perl) to add HTML links in text

use sed or awk (or perl) to add HTML links in text

Post by Susan Johns » Thu, 31 Jul 2003 03:56:25



I have an input file that looks like this:

 DFT000000018500 Fix LoggingServer script  The LoggingServer script in
                 to not look for classes   LoggingServer/scripts
                 by default                has been set up so that its
                 ...                       ...
 DFT000000018501 ...

I want to add HTML format so that it looks like this:

 <a href="http://remedy.pegs.com/arsys/servlet/ViewFormServlet?server=arcluster...
22DFT000000018500%22">DFT000000018500</a> Fix LoggingServer script
The LoggingServer script in
                 to not look for classes   LoggingServer/scripts
                 by default                has been set up so that its
                 ...                       ...
href="http://remedy.pegs.com/arsys/servlet/ViewFormServlet?server=arcluster...
22DFT000000018500%22">DFT000000018501</a> ...

Is there a way to accomplish this using sed or awk, or is perl the
only way?

 
 
 

use sed or awk (or perl) to add HTML links in text

Post by eryb » Thu, 31 Jul 2003 06:10:57



> I have an input file that looks like this:

>  DFT000000018500 Fix LoggingServer script  The LoggingServer script in
>                  to not look for classes   LoggingServer/scripts
>                  by default                has been set up so that its
>                  ...                       ...
>  DFT000000018501 ...

> I want to add HTML format so that it looks like this:

>  <a href="http://remedy.pegs.com/arsys/servlet/ViewFormServlet?server=arcluster...
> 22DFT000000018500%22">DFT000000018500</a> Fix LoggingServer script
> The LoggingServer script in
>                  to not look for classes   LoggingServer/scripts
>                  by default                has been set up so that its
>                  ...                       ...
> href="http://remedy.pegs.com/arsys/servlet/ViewFormServlet?server=arcluster...
> 22DFT000000018500%22">DFT000000018501</a> ...

> Is there a way to accomplish this using sed or awk, or is perl the
> only way?

Try this:
sed 's/\(DFT.[^ ]*\)/\<a href="URL">\1\<\\a\>/' < data > new_data
and inplace of URL put in the full link. The '\1' is the DFT string so
place that where you want the string to show up. This should work as
long as your links begin with a 'DFT'. DONT FORGET TO ESCAPE '\' the
right chars.

 
 
 

use sed or awk (or perl) to add HTML links in text

Post by Peter S Tillie » Thu, 31 Jul 2003 11:19:26



> I have an input file that looks like this:

[...]

> Is there a way to accomplish this using sed or awk, or is perl the
> only way?

You also asked this question in comp.lang.awk, where it was answered.

You should check out how to cross-post to multiple groups when you need
too do so and set up the "follow-up to" field so that people only need
to check in one NG whether you have received an answer.  This saves
everyone's time in the long run.

HTH
--
Peter S Tillier
"Who needs perl when you can write dc, sokoban,
arkanoid and an unlambda interpreter in sed?"

 
 
 

1. add blank lines after word MAC (sed/awk or perl??)

I have a file with the following data

192.168.60.161 DOMAINNAME-POWER       03U
192.168.60.161 DOMAINNAME-TEMP        1eU
192.168.60.161 MAC 00-xy-zz-07-bd-8a
192.168.60.179 DOMAINNAME-abacdf      00U
192.168.60.179 DOMAINNAME             00U
192.168.60.179 DOMAINNAME-abacdf      20U
192.168.60.179 DOMAINNAME             1eU
192.168.60.179 MAC 00-xy-8b-1c-08-c7
192.168.60.198 DOMAINNAME-abcd        00U
192.168.60.198 DOMAINNAME             1cU
192.168.60.198 DOMAINNAME             00U
192.168.60.198 DOMAINNAME-abcd        20U
192.168.60.198 DOMAINNAME             1bU
192.168.60.198 DOMAINNAME             1eU
192.168.60.198 DOMAINNAME             1dU
192.168.60.198 MAC 00-zz-aa-bb-8f-35

what I want to do is add blank line after MAC entry for each IP. I am
confortable with awk/sed but can't seem to fig. this out.

do I need perl? or can sed/awk do this?

2. IP Forwarding problem on Red Hat 9.0

3. Using awk or perl or sed to format/combine rows

4. Linux on a DSP

5. Serving text/x-server-parsed-html not text/html

6. maxphys and veritas

7. Need sed or awk solution for recursive html site.

8. Can't get Linux installed (InfoMagic march 1995)

9. where to start: cut & paste, perl, sed, or awk?

10. How to print a word following a pattern in sed, awk or perl

11. SED script that converts plain text (.txt) --> .html

12. sed awk or perl for this?

13. sed/awk/perl multi-line search/replace