This page was generated from 33.ed+ex.mth.

This page is part of the course work for CS360: Systems Tools course offered by the Computer Science Department at CalState, San Bernardino, California, USA. It was generated by Dr. Dick Botting.

Contents


    cs360/notes/33.ed+ex and also awk

    Why

    You have to use an editor to make 'vi' and 'emacs' work sometimes. And if they don't work.... what's left?

    Sheer unadulterated power: Editting 40 files with a single command.

    The rush of Extreme Editing:-)

    To program a repetitive action on a file.

    Sections


    (why): 33.01 33.02
    (exam): 33.03 33.04 33.05
    (useful): 33.02 33.03 33.04 33.05 33.07
    (PostIt Note): 33.03 33.04 33.11
    (perhaps): 33.06 33.08 33.12
    (skip): 33.09 33.10
    (wrong):

    Facts

    I use ed, ex, and awk all the time -- mainly inside scripts.

    Even mail and mailx were influened by ed and ex.

    Definitions

  1. normal_ed_command::= ed file.
  2. batch_ed_command::= ed - file <<terminator eoln commands terminator

  3. command::= addresses action.
  4. action::=following
  5. addresses::= empty | address | address, address | whole_file_indicator | global_edit.
  6. global_edit::= g/ pattern /.
  7. address::= simple_address | relative_address | simple_address plus_or_minus number.
  8. relative_address::= + number | - number | + | - .
  9. simple_address::= before_top | last_line | current_line | marked_line | next_line_to_match | previous_line_to_match.
  10. before_top::= 0.
  11. last_line::= $.
  12. current_line::= period.
  13. marked_line::= ' letter.
  14. next_line_to_match::= / pattern /.
  15. previous_line_to_match::= ? pattern ?.
  16. whole_file_indicator::= %

  17. normal_string_delimeter::= /.

    Edit Actions and Symbols

  18. append::= a lines.
  19. change::= c lines.
  20. delete::= d.
  21. edit::= e force_it_option other_file_symbol | e force_it_option file_name.
  22. other_file_symbol::= #.
  23. insert::= i lines.
  24. move::= m address.
  25. print::= p.
  26. quit::= q.
  27. read::= r source.
  28. source::= file_name | ! unix_command.
  29. substitute::= s / old_string / new_string / flags.
  30. flags::= any of g(global) + c(confirm) + p(print result).
  31. old_string::=pattern | empty.
  32. new_string::=any string of characters but escape special chars like & and /. copy.
  33. write::= w force_it_option append_it_option destination_option.
  34. force_it_option::= empty | ! .
  35. append_it_option::= empty | >>.
  36. destination_option::= empty | file_name.
  37. Symbols::=following

  38. pattern::= See http://www.csci.csusb.edu/dick/cs360/notes/26.patterns.html
  39. pattern::= See http://www.csci.csusb.edu/dick/cs360/notes/26.patterns.html
  40. file_name::==http://www.csci.csusb.edu/dick/cs360/notes/18.files.html#filename
  41. file_name::==http://www.csci.csusb.edu/dick/cs360/notes/18.files.html#filename

  42. number::=decimal number.
  43. letter::= a..z.
  44. empty::=

  45. TBA::=To Be Answered.

    See also

    An example of using ed to set up the notes for this class.... I needed to move the "Questions" section to the end of the notes and did it with an 'ed' script //www/dick/cs360/notes/fix.ed //www/dick/cs360/notes/fix.ed

    As another example, I was asked how to put a line in front of a file (its easy to add a line at the end with

     		echo line >>file
    ) but how to prepend a line into file. Answer the [ prepend ] script. You call it like this:
     		prepend file_name line to put in front of file

    Awk

    Awk is both useful and on the final exam, See
  46. awk::= See http://www.csci.csusb.edu/dick/cs360/notes/awk.html
  47. awk::= See http://www.csci.csusb.edu/dick/cs360/notes/awk.html

    Questions

    Answer the following questions about the 'ed' editor: [ Questions in awk ] [ Questions in awk ]

    Submit Your Notes Here

    To earn credit for completing this part of the course you need to send me a short list of things you have learned. A simple way to do this is to follow this [click here [socket symbol] if you can fill this hole] link and fill in the form.

End