home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #3 / NN_1993_3.iso / spool / comp / unix / question / 15859 < prev    next >
Encoding:
Internet Message Format  |  1993-01-23  |  2.3 KB

  1. Xref: sparky comp.unix.questions:15859 comp.unix.shell:5470
  2. Newsgroups: comp.unix.questions,comp.unix.shell
  3. Path: sparky!uunet!mcsun!sunic!palantir.p.tvt.se!infolog!mich
  4. From: mich@lin.infolog.se (Thomas Michanek)
  5. Subject: Need help understanding sed
  6. Message-ID: <1993Jan22.210855.29212@infolog.se>
  7. Sender: news@infolog.se
  8. Organization: Infologics, Linkoping, Sweden
  9. References: <1993Jan22.140947@is.morgan.com>
  10. Date: Fri, 22 Jan 1993 21:08:55 GMT
  11. Lines: 44
  12.  
  13.  
  14. I've started to use 'sed' a lot, not only for simple 's/.../.../'
  15. substitutions, but I have trouble understanding the man page for sed
  16. when trying to using more complex commands. Could someone help me
  17. with the following issues:
  18.  
  19. 1. The man page sais:
  20.  
  21.      Some commands use a hold space to save all or  part  of  the
  22.      pattern space for subsequent retrieval.
  23.  
  24.    However, I can't find _which_ commands do that and how. I've tried
  25.    using the g, G, h, H, x commands, but sed produces no output.
  26.  
  27. 2. "\n" in a context address is supposed to match a NEWLINE in the
  28.    pattern space. But doesn't sed read one line at a time into the
  29.    pattern space, each line separated by NEWLINE?
  30.  
  31.    I want to look for files containing the pattern "A" in one line
  32.    and the pattern "B" in the next line. The following doesn't work:
  33.  
  34.      sed '/A\nB/p'
  35.  
  36.    How can you do such a 'multi-line grep'?
  37.  
  38. 3. What's the difference between the commands n and p? The man page sais 
  39.    n copies the pattern space to stdout, but it has never worked for me.
  40.  
  41. 4. What's the syntax for the { } command grouping? No matter how I try
  42.    I get "Extra text at end of command" or "Unrecognized command".
  43.  
  44.    Isn't sed '/A/{=;p}' supposed to print the line number and the pattern
  45.    on stdout? I've tried quoting, backslashing, spaces, no semicolon etc.
  46.  
  47. BTW, I'm using C shell on SunOS4.1.1 and "sed0.c 1.15 89/03/28 SMI".
  48.  
  49. Your aid is urgent and welcome!!!
  50.  
  51. .- - - - - - - - - - - -.  _ _  _ ___ _  _   _   _  _  _  _   .- - - - - - - -.
  52. |    Thomas Michanek    |  | |\ | |_ / \ |  / \ / _ | / `|_`  | Dial +46 13   |
  53. |  Infologics Linkoping |  | | \| |  \_/ |_,\_/ \_| | \_,._|  | 210060  Phone |
  54. | email:Thomas.Michanek |          _                          | 210068  Direct|
  55. |       @lin.infolog.se |  L I N K O P I N G  -  S W E D E N  | 210155  Fax   |
  56. `- - - - - - - - - - - -'                                     `- - - - - - - -'
  57.