Re: [ILUG] Opposite of Cat >>

From: Brian Foster (blf at domain utvinternet.ie)
Date: Mon 10 Jun 2002 - 12:58:39 IST


  | Date: 07 Jun 2002 22:57:43 +0100
  | From: Mark Finlay <sisob at domain eircom.net>
  |
  | I have an install script which `cat >>`'s [ ... ] into ~/.gnome/session-manual
  | [ ... ] I need to write an unistall script that will remove that text from the
  | file bearing in mind there could be text before and after that block that
  | need to be left intact and [ the text block itself may have been altered ].

 if you have control of the install script and/or injected
 text block, an approach is to alter that text block to be
 of the form:

     a magic marker line meaning "begin"
     the text block (as many lines as you wish, containing
     whatever you wish, as long as none could be confused
     with either of the two magic marker lines) ...
     a magic marker line meaning "end"

 this is trivial to un-install --- just delete all lines
 between (and including) the two magic marker lines.
 numerous tools can do this, sed(1) is perhaps a good
 choice --- _and_ you don't have to master REs (unlike
 the more obvious approach of explicitly searching for
 and deleting all the known-to-have-been-added lines).

 the format of those magic marker lines depends, mostly,
 on the format of the file in question. e.g., if it has
 a `#'-comment convention, they might be of the form:

     #BEGIN "my-package-name" !DO _NOT_ CHANGE THIS LINE!
     #END "my-package-name" !DO _NOT_ CHANGE THIS LINE!

cheers!
        -blf-

--
 Innovative, very experienced, Unix and      | Brian Foster    Dublin, Ireland
 Chorus (embedded RTOS) kernel internals     | e-mail: blf at domain utvinternet.ie
 expert looking for a new position ...       | mobile: (+353 or 0)86 854 9268
  For a résumé, contact me, or see my website  http://www.blf.utvinternet.ie
    Stop E$$o (ExxonMobile):  «Whatever you do, don't buy Esso --- they
     don't give a damn about global warming.»    http://www.stopesso.com
     Supported by Greenpeace, Friends of the Earth, and numerous others...


This archive was generated by hypermail 2.1.6 : Thu 06 Feb 2003 - 13:17:10 GMT