1758569 Members
1978 Online
108872 Solutions
New Discussion юеВ

script to modify file

 
SOLVED
Go to solution
tom quach_1
Super Advisor

script to modify file

Hi All,

i have a script to search for oracle alert log file "ORA-" and it is working fine.
i would like to do: when it find "ORA-", it will add a character like " A" to "ORA" like this "AORA" and save the file.
is it possible.
Please help.
Thanks,
Tom
3 REPLIES 3
James R. Ferguson
Acclaimed Contributor
Solution

Re: script to modify file

Hi Tom:

This could be as simple as:

# perl -pi.old -e 's/ORA-/AORA-/' logfile

This performs an in-place update, preserving a backup copy of the file as "*.old".

Regards!

...JRF...
tom quach_1
Super Advisor

Re: script to modify file

Thanks James,

It works,

if i just want to search for ORA- and not AORA-
i am using grep ORA- now and the result :
ORA- AND AORA-
how can i limit the search only to ORA- but not AORA-.
Thanks very much for your help.
James R. Ferguson
Acclaimed Contributor

Re: script to modify file

Hi (again) Tom:

# perl -pi.old -e 's/\bORA\b/AORA/' logfile

This substitutes "AORA" for the sequence "ORA" when "ORA" is bounded by a "word" boundary. That is, where there is a "word character" on one side but not the other.

Regards!

...JRF...