Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9180949
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T18:10:23+00:00 2026-06-17T18:10:23+00:00

Currently I’m trying to create a bash script for replacing new values I generated.

  • 0

Currently I’m trying to create a bash script for replacing new values I generated.

These values were stored in constants.php:

-----------constant.php : start-------------------
                      :
        define('PASS1', 'ABCD');
        define('PASS2', '1234');
                      :
-----------constant.php : end---------------------

After running script, (using sed) it should update the values of PASS1 and PASS 2 separately:

-----------constant.php : start-------------------
                      :
        define('PASS1', 'WXYZ');
        define('PASS2', '0987');
                      :
-----------constant.php : end---------------------

Is there a way I can find the KEY e.g. 'PASS1' and replace the values after the comma?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T18:10:24+00:00Added an answer on June 17, 2026 at 6:10 pm

    You can specify the occurrence with sed so sed "/PASS1/s/'[^']*'/'WXYZ'/2" matches any lines containing PASS1 and does the following substitution s/'[^']*'/'WXYZ'/2 which:

    s/     # Substitute  
    '      # Match a single quote
    [^']*  # Match anything not a single quote 
    '      # Match the closing single quote 
    /      # Replace with 
    'WXYZ' # The literal value
    /2     # The 2 here matches the second quoted string, not the first.  
    

    # First key 
    $ sed "/PASS1/s/'[^']*'/'WXYZ'/2" file
    
            define('PASS1', 'WXYZ');
            define('PASS2', '1234');
    
    # Second key
    $ sed "/PASS2/s/'[^']*'/'0978'/2" file
    
            define('PASS1', 'ABCD');
            define('PASS2', '0978');
    
    # In one go
    $ sed "/PASS1/s/'[^']*'/'WXYZ'/2;/PASS2/s/'[^']*'/'0978'/2" file
    
            define('PASS1', 'WXYZ');
            define('PASS2', '0978');
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Currently, these are my codes to create a picker view genderPicker = [[UIPickerView alloc]
Currently I'm starting a new Activity and calling finish on a current one. Is
Currently I have this code: <?php echo '<meta name=robots content=noindex>'; $arr = json_decode(file_get_contents(http://media1.clubpenguin.com/play/en/web_service/game_configs/ paper_items.json),true);
Currently I am trying to use a bunch of custom perl modules, test.pm as
I want use html5's new tag to play a wav file (currently only supported
Currently using Oracle/BEA/Plumtree ALUI Portal 6.1, and am trying to display a client's IP
currently I am trying to replace a simple HTML element to alert the user
Currently I am trying to make my app available for iOS4, to increase the
Currently I am trying to change the icon of a particular feature of a
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.