Issue
I have file which contain below string in file.
ALTER DATABASE RENAME FILE '/home/oracle/oradata/undotbs01.dbf' TO '/home/oracle/oradata/undotbs01.dbf';
With bash methods I want to replace second "undotbs01.dbf" to another name. When I did it with grep and sed it changes all undotbs01 words in file, to the new value. But I need only second undotbs (which located after "TO" word) to be changed.
Solution
Using sed
sed 's/undotbs01\.dbf/new_value/2' input_file
ALTER DATABASE RENAME FILE '/home/oracle/oradata/undotbs01.dbf' TO '/home/oracle/oradata/new_value';
Answered By - HatLess Answer Checked By - Cary Denson (WPSolving Admin)