See this page in (approximate): Español| Français| Italiano| Deutsch| Português

Some Sed Links

[make a comment about (or add to) this document]

1. INTRO
2. NOTES
3. LINKS
4. CONVERTING SED TO OTHER THINGS
5. MISCELANEOUS



1.  INTRO [TOC]

   This page contains some information and links about the sed editor
   Sed stands for 'stream editor' and is a way of 'editing' text files.
   Sed grew and lives in the Unix world. It has two close cousins; Grep
   and Awk. Awk in some ways is an enhanced sed, but is also designed for a
   slightly different purpose. My only reservation about Awk is that string
   substitutions do not seem as easy as in Sed.

   Sed is essentially an extremely small and simple but elegant programming
   language. For example, in Sed only two variables are allowed: the 'hold-space'
   variable, and the 'pattern-space' variable. In sed there is only one
   conditional statement 'if', and only one conditional operator 'matches' (and
   'does not match'). In Sed only one type of iteration is allowed, and that is the
   iteration over lines in a text file in sequential order. All these limitations may
   make it sound as if it would be difficult to do anything useful in Sed, but that
   is not the case. This is owing to sed's 'understanding' of 'regular expressions'
   or search patterns (as they are often called in the Microsoft World).

   Because Sed is such a restricted language, many things cat be 'omitted' or left
   implicit in a sed program. For example, the following is a Sed program:
     "/^b/ {h;s/5/6/g;}"

   What this actually means in terms of more normal programming languages, is the following
   (I am using a kind of 'pseudo code' here)
    
     OPEN a file for reading
     for each (line in the current-file)
     do
       SET the-hold-space = the-current-line
       SET the-pattern-space = the-current-line
       if (the line) MATCHES (the first character is a 'b')
       then
        
         SET the-pattern-space = [SUBSTITUTE all '5's with '6's in the-current-line]
         PRINT the-pattern-space TO THE SCREEN
       endif
     done

    As can be seen, quite a lot of 'pseudo code' is required in order to represent
    a very small 'sed' program.
    

2.  NOTES [TOC]
    Using gnu sed version 3.02.8 (NOT 3.02) you can insert new-line characters in the
    right hand side of the sed replacement expression. (\n). Also you can use the
    notation \xnn for hex code replacement. 3.02 does not have these features.

3.  LINKS [TOC]

   [*]http://www-106.ibm.com/developerworks/linux/library/l-sed3.html
     A nice, reasonably advanced sed tutorial with scripts and
     explanations of why they work. Also an explanation of
     hold and pattern spaces. thankyou. This also contains a link to the latest version
     of GNU sed (3.02.8).
    
   [*]http://www.student.northpark.edu/pemente/sed/index.htm  
   [*]http://www.cornerstonemag.com/sed/
     Pretty much the SED 'home' page. Includes and FAQ to html conversion script
     (which does hyperlink the table of contents and appears to 'chunk' the HTML but
     this script does not appear to be the one eric acually uses to make his FAQ)
     This site is quite Microsoft Windows oriented.
     This site may not always be available.
    
   [*]http://sed.sourceforge.net/
     Another important sed site. Good sed links. Lots of advanced sed scripts including
     a comprehensive HTML entity to 'iso' script, a hyper-link url extracting script ...
     ALSO an 'iso2html' script which does what my 'html-entities.sh' script does but
     better (since it doesnt have to use the 'echo' command).

   [*]http://sed.sourceforge.net/grabbag/
     More scripts

   [*]http://www.student.northpark.edu/pemente/sed/sedfaq.html
     The very good seq faq. This is very detailed and scholarly although many of the links
     may be out of date. This page contains some nice CSS styles for formatting the
     headings. And the FAQ appears to have been produced with a reasonably 'clean' script
     (but I dont know what the script is).

     Section 4.7 deals with control characters and special characters (such as accented
     characters).
     The CSS styles should be useable for my own sed scripts.

   [*]http://www.student.northpark.edu/pemente/sed/bookindx.txt
     A book indexing sed script by the FAQ man.

   [*]http://main.rtfiber.com.tw/~changyj/sed/
     An actively maintained (april 2003) and swish looking SED site. Good swish HTML using
     style sheets.
    
   [*]http://www.gnu.org/manual/sed-3.02/sed.html
     The gnu manuals for Gnu Sed. This is not particularly thorough and does not contain any
     examples.

   [*]http://www.urc.bl.ac.yu/manuals/progunix/sed.txt
     An old but reasonably thorough  manual. Some examples. No  table of contents.
    
   [*]http://www.dbnet.ece.ntua.gr/~george/sed/OLD/1liners.txt
     Some one line sed scripts, including an example of replacing a 'hex coded' value (which
     probably DOESNT work in GNU sed)
     and some other quite tricky scripts

  Some important SED people
   Al Aab <[email protected]>   # "seders" list moderator
   Yiorgos Adamopoulos <[email protected]>
   Dale Dougherty <[email protected]>     # author of "sed & awk"
   Carlos Duarte <[email protected]>    # author of "do it with sed"
   Eric Pement <[email protected]>  # author of this document
   Ken Pizzini <[email protected]>          # author of GNU sed v3.02
   S.G.Ravenhall <[email protected]> # great de-html script
   Greg Ubben <[email protected]>      # many contributions & much hel
   Jeffrey Friedl   A regular expression guru
            
      
   [*]http://www.dbnet.ece.ntua.gr/~george/sed/OLD/sedtut_1.html
     Another, fairly good sed tutorial.
   [*]http://www.dbnet.ece.ntua.gr/~george/sed/OLD/
     Links to other sed stuff, including a text file 'indexing' script.

4. CONVERTING SED TO OTHER THINGS [TOC]

   As much as I like sed, as times it would be useful to have sed scripts in other
   languages. Since sed mainly consists of regular expressions and substitutions, which
   are implemented in many language, it would seem not too difficult to convert a
   sed script to something else.

   [*]http://sedsed.sourceforge.net/README
     A sed code beautifier, indenter and HTMLiser. Written in the python language.
     It also does 'tokenizing' which may be half way to parsing

5. MISCELANEOUS [TOC]

   echo -e "\121"
     This echos a capital q (Q) to standard out.
    echo "QQ" | sed 's/'$(echo -e "\121")'/x/g'
      This changes all occuraces of Q into x. 121 is the octal code for Q. We can use
      the to SED for special characters. This is necessary because I only have the
      3.02 version of sed, not the 3.02.8 version (which supports the \xnn notation)


    Below is a sed line which creates a script file which will HTML entitize files which
    contain accented characters etc.
    cat html-entities.sh | expand | tr -s ' ' | tr ' ' '\n' | sed -n "/^\".[0-9]/{N;s/\n/ /g;p;}" | sed "s/\(\"[^\"]\+\"\),[ ]*\"\([^\"]\+\)\".*/sed 's|'\$(echo \-e \1)'|\2|g' /g" | less

[*]http://wuarchive.wustl.edu/mirrors/NetBSD/NetBSD-current/pkgsrc/textproc/README.html
    A page containing a link to a catalan dictionary for Ispell
    
[*]http://dataconv.org/apps_source.html
    A page with a link to a Awk to C translator.

  JAD is a java decompiler
  'masterplant' is stated to be an automatic parser which generates xml style code.

[*]http://www.cs.rit.edu/~afb/20013/plc/slides/perlintro.html
    A perl tutorial. Some simple examples. Swish HTML


BACK TO THE TABLE OF CONTENTS
If you wish, you may add a comment, suggestion or other contribution which will appear at the end of this document.
Any input you make is greatly appreciated.


Your Comment (or other contribution to this document)


Your Name [OPTIONAL BUT NICE]


See this page in (approximate): Español| Français| Italiano| Deutsch| Português
Hosted by www.Geocities.ws

1