Can I do it with sed?
From: Bill Campbell (campbell_at_nrlmry.navy.mil)
Date: 08/27/03
- Previous message: Stephane CHAZELAS: "Re: TERM = VT100 ... What Are Other Options?"
- Next in thread: Alan Connor: "Re: Can I do it with sed?"
- Reply: Alan Connor: "Re: Can I do it with sed?"
- Reply: Charles Demas: "Re: Can I do it with sed?"
- Reply: Edgar Allen: "Re: Can I do it with sed?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 27 Aug 2003 09:56:28 -0700
I'm trying to insert a fixed set of comment lines after the end of a
subroutine declaration in a Fortran program. Subroutine declarations
can either be on one line, vis.
subroutine not_too_many_args(arg1,arg2)
c Here's where I want the comment to go
integer :: it(10)
c ... but not here, or anywhere else in the file
... or they can span several lines, vis.
subroutine why_so_many_args(arg1,arg2,
& arg3,arg4,
x arg5,arg6,
3 arg7)
c Here's where I want the comment to go
integer :: not_here(20)
c ... but not here
,or_here(30)
c ... or here, or there, I do not want it anywhere.
What I have is a sed script that does not work:
/subroutine/,/)/s/)/)\
c Here is the comment\
c and furthermore/
The first pattern matches the first line, but the second pattern
matches some later line in the first case (one-line subroutine
declaration), while it works nicely in the second case (multi-line
subroutine declaration). I guess I could use grep and split up the
separate cases (I have several hundred subroutines to update), but I
was hoping for a more elegant solution, ideally just using sed (what
can I say, I like sed).
- Previous message: Stephane CHAZELAS: "Re: TERM = VT100 ... What Are Other Options?"
- Next in thread: Alan Connor: "Re: Can I do it with sed?"
- Reply: Alan Connor: "Re: Can I do it with sed?"
- Reply: Charles Demas: "Re: Can I do it with sed?"
- Reply: Edgar Allen: "Re: Can I do it with sed?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]