sed append word at end of line if word is missing
I have to modify formsweb.cfg file in Oracle IAS.
Problem description In formsweb.cfg file are two lines with labels archive_jini= and archive= at the beginning of line. After equal sign (=) is row of filenames of java archives delimited by coma(,). When I insert a new jar file in java directory, I have to append the very same name of jar file to both lines if that name is not yet present. I would appreciate some (a lot!!!) help. :banghead: example snippet from formsweb.cfg # Forms applet parameter serverApp=default # Forms applet archive setting for JInitiator archive_jini=frmall_jinit.jar,images.jar,paketi.jar,imgbean.jar # Forms applet archive setting for other clients (Sun Java Plugin, Appletviewer, etc) archive=frmall.jar,images.jar,in2kartica.jar,classes12.jar,HTTPClient.zip,imgbean.jar # Number of times client should retry if a network failure occurs. You should # only change this after reading the documentation. networkRetries=30 |
I think this should do it, assuming the sample is representitive of the whole. It works for me in testing:
Code:
sed -i.backup '/^archive/ {/foo.jar/! s/.*/&,foo.jar/}' formsweb.cfg The -i option edits the file in place, with .backup creating a backup of the original. |
And I was brain shaking :banghead: in my head for two days!
THX :hattip: Regards Franjo |
This is exactly what I was looking for tonight... David the H., you're the man... :)
|
All times are GMT -5. The time now is 07:28 PM. |