Re: sed script to insert text
From: rakesh sharma (sharma__r_at_hotmail.com)
Date: 12 Sep 2003 20:11:26 -0700
firstname.lastname@example.org (Narahari) wrote in message news:<email@example.com>...
> 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
> insert // at the beginning of the line making the above lines look
> // 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.
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.