Sed challenge

Sed challenge

Post by Dr. Yuan Li » Fri, 22 May 1998 04:00:00




> Input:
> <OPTION VALUE="'SUN INT'L CARPETS'"> SUN INT'L CARPETS

> To look like this:
> <OPTION VALUE="'SUN INT''L CARPETS'"> SUN INT'L CARPETS

To be on the safe side, you want to leave as much fixed pattern as
possible.  e.g.,



Didn't test.  If this is a Webification task, it could be easier if the
input is simply
 SUN INT'L CARPETS

Quote:> J.Chichester

--

|         Dr. Yuan LIU           -     Chitech Technologies Inc.  |
+------- (514)281-0494 ------------------ FAX (514)281-0493 ------+
 
 
 

1. sed challenge

i want to reformat the output of archie to be compatible with that of
web browsers.  More concisely:
$ archie beer

Host ftp.belwue.de

    Location: /news/spool/overview/alt
      DIRECTORY drwxr-xr-x        512  Jul 17 1994  beer
    Location: /news/spool/overview/rec/food/drink
      DIRECTORY drwxr-xr-x        512  Jul 17 1994  beer

Host ftp.uni-oldenburg.de

    Location: /pub/unix/sysadmin
      DIRECTORY drwxrwxr-x        512  Mar  6 1993  beer

Host rtfm.mit.edu

    Location: /pub/usenet-by-hierarchy/alt
      DIRECTORY drwxrwxr-x        512  Apr 12 11:45  beer
    Location: /pub/usenet-by-hierarchy/rec/food/drink
      DIRECTORY drwxrwxr-x        512  Mar 30 03:26  beer

Host nic.funet.fi

    Location: /pub/culture
      DIRECTORY drwxrwxr-x        512  May 22 1994  beer
    Location: /pub/pics/misc
      DIRECTORY drwxrwxr-x        512  May  7 1994  beer

Host ftp.elte.hu

    Location: /software/unix/sysadmin
      DIRECTORY dr-xr-xr-x        512  Sep 16 1993  beer

$ script beer
ftp://ftp.belwue.de/news/spool/overview/alt/beer
ftp://ftp.belwue.de/news/spool/overview/rec/food/drink/beer
ftp://ftp.uni-oldenburg.de/pub/unix/sysadmin/beer
ftp://rtfm.mit.edu/pub/usenet-by-hierarchy/alt/beer
ftp://rtfm.mit.edu/pub/usenet-by-hierarchy/rec/food/drink/beer
ftp://nic.funet.fi/pub/culture/beer
ftp://nic.funet.fi/pub/pics/misc/beer
ftp://ftp.elte.hu/software/unix/sysadmin/beer

i was able to do this with a simple awk script:

#!/bin/sh

                        /Location/  {dir = $2};  \
                        /DIRECTORY/ {print "ftp://" host dir "/" $NF}'

is it possible to do this using sed only?
will it be faster with sed (sed spends less time parsing its input)?
--

        -dave harif

2. Defining $MANPATH globally

3. challenge - sed and/or awk

4. netscape and backspace

5. Challenge for 'sed'

6. ircd2.6 and ircII.2.2.6 under Linux

7. sed(1) challenge

8. Is there a Mosaic+term+SOCKS combo?

9. sed sed sed

10. . 2 sed FAQs, sed exes, sed cetras; URLs

11. SED SED SED...

12. (sed 1q ; sed 2q) : no output from 2nd 'sed'

13. . sed script dc greg ubben sed stud