0

I have a below content in a file where i need to search the pattern "application:" , where "application:" should be there but the next field to it should be changed to "RMAN" , I am trying to do with sed but unable to get it in one go.. any help appreciated

$ cat myjobs

update_job: P_rman_INC1_HCMS2 job_type: CMD

group: DBA

application: RMAN

update_job: P_rman_INC1_HCMPRTL job_type: CMD

group: DBA

application: Mybox

0

Assuming the example input you gave:

sed -e 's/application:.*/application: RMAN/g' filename
0

For a simple output printing

sed -e 's/application:.*/application: RMAN/p' filename

To modify the file directly

sed -i 's/application:.*/application: RMAN/g' filename

Also you can modify one by one in case you want to change a specific application: line.

$ vim myjobs
~
~
~
~
:%s/application: /application: RMAN/gc

This will ask you line by line if you want to replace the pattern or not.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.