We help IT Professionals succeed at work.
Get Started

automate find and replace inside jar on linux platform

enthuguy
enthuguy asked
on
119 Views
Last Modified: 2018-02-06
Hi Experts

Would like to get your advise on what is the best way to automate replacing files inside jar files on Linux platform.

scenario:
1. We will have a directory "fixes" with all the code fix files. E.g xml, .class, .properties
2. We will have another directory with jar files one or more files (where all the fixes will go in)
3. Need your help in writing a script.
      a. Each jar should be unjar/unzip to a tmp directory
      b. Go through each code fix file one by one inside "fixes" directory
      c. Search inside unjar tmp location and replace.
      d. Take next code fix file, search again inside the same unjar tmp location and replace. Basically to find/replace all code fix files.
      e. Once all done. jar the file and clear tmp
      f. Now unjar next jar file and repeat from a to e.


Interesting part is
1. single code fix could be in multiple jar files
2. multiple code fix could be in single jar as well.


will try to upload sample files
Comment
Watch Question
CERTIFIED EXPERT
Distinguished Expert 2020
Commented:
This problem has been solved!
Unlock 1 Answer and 2 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE