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 8751287
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T13:01:01+00:00 2026-06-13T13:01:01+00:00

I am writing a script to try and speed up my basic WordPress installation.

  • 0

I am writing a script to try and speed up my basic WordPress installation. It downloads the latest version, unpacks it, changes to the clients name and then updates some text in the config file.

I am however having trouble inserting multiple lines which contains special characters using sed. The multiple lines are from the WP Secret Key Generator https://api.wordpress.org/secret-key/1.1/salt/ and they are to replace the standard

define('AUTH_KEY',         'put your unique phrase here');
define('SECURE_AUTH_KEY',  'put your unique phrase here');
define('LOGGED_IN_KEY',    'put your unique phrase here');

etc…

Here is the bit of code that is giving me the issue

# Download data to variable
salt="`curl https://api.wordpress.org/secret-key/1.1/salt/`"

sed -i "/NONCE_SALT/a $salt" $pname/wp-config-sample.php

I am downloading the generated text to a variable and then looking to insert, on a new line, after the last instance in the standard text (I will later delete all of these standard lines). It throws up an error of;

"ed: -e expression #1, char 112: extra characters after command" 

When I enter a single line of standard text it is fine. If I add quotation marks around the $salt it just prints the literal $salt in the file.

Is sed the right approach for inserting this data? Keeping in mind I need to insert after a specific point in the file?

Any hints or tips are more than welcome. This is my first attempt at a bash script.

  • 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-13T13:01:02+00:00Added an answer on June 13, 2026 at 1:01 pm

    The a function requires that a backslash precede any internal newline in the string. So, one approach is to use sed to add the necessary backslashes:

    # Download data to variable, adding \ to all but the last line:
    salt="$(curl https://api.wordpress.org/secret-key/1.1/salt/ | sed '$ ! s/$/\\/')"
    
    sed -i "/NONCE_SALT/a $salt" "$pname/wp-config-sample.php"
    

    (Note that I used $(...) instead of `...`: the latter has painful quoting rules. In this case I’d have had to write \\\\ instead of \\.)

    That said, in this case I think it might be simpler to save the salt-stuff to a temporary-file, and use r instead of a:

    # Download data to the file salt.txt:
    curl https://api.wordpress.org/secret-key/1.1/salt/ > salt.txt
    
    sed -i "/NONCE_SALT/r salt.txt" "$pname/wp-config-sample.php"
    
    rm salt.txt      # could also be done in a trap
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am writing a script that parses an internet site (maya.tase.co.il) for links, downloads
I'm writing my second python script to try and parse the contents of a
I'm writing a python script to perform some basic CM functions like tagging in
I'm writing script in remote.ini The script looks like on 1:start:{ server some.irc.server server
im writing a script to get services from local and remote machines. I've had
I am writing a script in perl where I use forking and I need
I'm writing a script, and it requires to get a reCAPTCHA challenge with a
I am writing a script to convert a picture into MIDI notes based on
I am currently writing a script which parses the ServiceTage, Computername and Username from
I am writing a script to install patches on Windows boxes. The best methodology

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.