Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

214
Views
sed command not searching for string correctly and replacing

I'm currently deploying a new webapp (GEM) for a project. When updating the user data, it's not correctly searching for the string and replacing it in the workers.properties file in apache. The current script I'm using to do this is:

sed -i "s/worker.list\=GMA,jkstatus/worker.list\=GMA,ETL,common-resource,GAA,authzmanager,Launch,jkstatus/g" ${INSTALL_BASE}/${APACHE_DIR}/conf/jk/workers.properties

the current line of code needing changed in workers.properties is the following:

worker.list=GMA,ETL,common-resource,GAA,authzmanager,Launch,jkstatus

The change im trying to make is just this:

worker.list=GMA,ETL,common-resource,GAA,GEM,authzmanager,Launch,jkstatus

Is there something not right in the search? It's changing other things in the file, so it's definitely able to access workers.properties. Any help on this is appreciated.

EDIT: I have confirmed that it does not like the comma in between GMA,jkstatus indicating to start at GMA and end at jkstatus:

\=GMA,jkstatus/ So how do I tell sed to stop on jkstatus instead of using a comma?

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

You can match any text after worker.list= using worker\.list=.*:

sed -i 's/worker\.list=.*/worker.list=GMA,ETL,common-resource,GAA,authzmanager,Launch,jkstatus/' ${INSTALL_BASE}/${APACHE_DIR}/conf/jk/workers.properties

To remove only the first occurrence in the file you may use

sed -i '0,/worker\.list=.*/s//worker.list=GMA,ETL,common-resource,GAA,authzmanager,Launch,jkstatus/' ${INSTALL_BASE}/${APACHE_DIR}/conf/jk/workers.properties

Note 0,/pattern/ will remove only the first occurrence in the file.

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!