SED - case insensitive pattern restriction
Hi,
I have a lot of Oracle DB package bodies in files and need to replace the names of internal called procedures/functions.
A small example:
suppose we want to change InsertCustomer to InsCust in a procedure like this:
PROCEDURE InsertCustomers () AS
BEGIN
SELECT InsertCustomer() FROM DUAL; -- this should be replaced
...
SELECT someOtherPackage.InsertCustomer() FROM DUAL -- this not
END InsertCustomers;
I need a restriction for sed, which excludes the lines 1,5 and 6 but in case insensitive mode (END can also be end or End, ...). There's an option /i in sed for the case insensitive mode, but that only applies for replacement and not for the restriction pattern.
I use following command, but that excludes only lines with PROCEDURE, FUNCTION, END in upper case and 'anything.InsertCustomer':
sed '/^\(PROCEDURE\|FUNCTION\|END\|.*\+\.InsertCustomer\)/ !s/InsertCustomer/InsCust/i'
I also need to have the ability to exclude lines like this:
anything.insertcustomer
anything.INSERTCUSTOMER
End
procedure
...
Thank you for any help.
Filip
|