[lug] simple text editing problem

Michael Deck deckm at cleansoft.com
Thu Aug 22 09:21:04 MDT 2002


[[Blunder: I didn't read the original post carefully and overlooked the "interactive" requirement. Sorry. My sed suggestion doesn't do that. ]]

Have you considered sed? What I do is to write a little sed script like 

  s/TextToReplace/Replacement/g 
  s/OtherTextReplace/OtherReplacement/g 

Then I created a shell script "sedexec" 

  #!/bin/bash
  echo ${1}
  cp ${1} ${1}.orig
  sed -f ~/sedscript ${1}.orig > ${1}

That way if something goes wrong I have the original file. 

Finally 

  find . -name 'filter' -exec ./sedexec {} \;

man sed and man find for details. 

At 09:42 PM 8/21/2002, you wrote:
>Well, maybe it's simple...
>
>I need to find and replace text from around 10,000 lines of c code in
>around 50 files in several directory trees.  I'm going to have to do this
>quite a few times, so the solution needs to be able to use "find" as the
>input for which files to load, or else remember from one day to the next
>which files I'm interested in.  Also, it has to be interactive, since I
>won't always be able to tell if I need to do the replace without context.
>
>I have found many, many solutions that can do almost what I am describing
>above.  So far I have not found anything that can do all of that.
>Probably Emacs can do it, but I don't know Emacs yet.  I have tried
>cooledit, nedit, jedit, kdevelop, and several others.
>
>Free/libre licensed solutions only please.
>
>If such a thing doesn't exist I will implement it in Perl and release it.
>
>_______________________________________________
>Web Page:  http://lug.boulder.co.us
>Mailing List: http://lists.lug.boulder.co.us/mailman/listinfo/lug
>Join us on IRC: lug.boulder.co.us port=6667 channel=#colug


Michael Deck
Cleanroom Software Engineering, Inc.   





More information about the LUG mailing list