Re: sed script to insert text

From: rakesh sharma (sharma__r_at_hotmail.com)
Date: 09/13/03


Date: 12 Sep 2003 20:11:26 -0700

savithari@yahoo.com (Narahari) wrote in message news:<ae30c156.0309121303.71407dcf@posting.google.com>...
> Hello:
> I have to comment a bunch of lines in my java code. The pattern
> to look for in my case is commitTransaction.
>
> If the line says
>
> super.commintTransaction();
>
> or
>
> obj.commitTransaction();
>
>
> insert // at the beginning of the line making the above lines look
> like
>
> // super.commitTransaction();
>
> // obj.commitTransaction();
>
> Is it possible to do it in sed, if so what is the <b>script</b> and a
> brief explanation would help.
>
> Thanks
> -Narahari

sed -e '/commitTransaction/s:^://:' javafile

## whenever sed sees 'commitTransaction' anywhere in a line, it puts
## '//' at the beginning(specified by the ^) of that line & prints it.
## and the non-matching lines are printed out unaltered.



Relevant Pages

  • Re: sed script to insert text
    ... The pattern ... > to look for in my case is commitTransaction. ... This sed command will look for lines containing the text ... The replacement ...
    (comp.unix.shell)
  • [opensuse] Information after unfinished Smart update
    ... After downloading a whole bunch of files, at the time of unpacking/installing ... I get this error information with which I do not know what to do with. ...
    (SuSE)