Results 1 to 2 of 2
I am trying to learn sed to automate some very boring editing that tends to follow a pattern.
For example, I have a set of Java files that require a ...
- 02-05-2009 #1Just Joined!
- Join Date
- Feb 2009
- Posts
- 3
sed novice requests assistance
I am trying to learn sed to automate some very boring editing that tends to follow a pattern.
For example, I have a set of Java files that require a standard header to be inserted. Some have no header, and some have an older, outdate version of the standard header.
So, I want to delete everthing up to but not including the the package statement, and insert the new header. For example, given the file
I would like to delete the old header and insert the new header.Code:/** * Old standard header */ package a.b.c; import d.e.f.SomeClass; public class SomeOtherClass { public static void main( String[] args ) { } }
Most of what I see as examples would seem to be based around the sed command:
However, that deletes the package line. I have tried variations that attempt to put the package line in the hold buffer, but it is clear to me that I don't understand what is going on there. Finally, if I include my insert statement in a block ending with the delete, it gets printed multiple times, but the package statement still does not get reprinted.Code:1,/package/ d
If I can solve this, I hope to generalize it to add a set of comments to methods that are concrete implementations of an abstract method in a set of concrete subclasses, so the method names and signatures are identical. Again, some have invalid method header comments, and some have no comments, but our ferschlunginger SDP requires a specific style of comments.
I'm tired of doing the cut and paste routine. Help me get my computer to do the work for me.
Thanks,
¦ {Þ
- 02-06-2009 #2Just Joined!
- Join Date
- Feb 2009
- Posts
- 3
Ahh, of course, no sooner than I posted than I figured it out. First rape, then pillage, THEN burn, as the old viking said to the youngster.
¦ {Þ


Reply With Quote