Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You can replace the single quotes in the sed command with double-quoted single quotes. The shell sees a single quote as ending a string. So, let it. You had</p> <pre><code>sed -i 's/'ADMIN_USERNAME','memcache'/'ADMIN_USERNAME','u'/g' /var/www/html/memcache.php </code></pre> <p>But, if you replace the ' in the sed command with '"'"', then shell will see the first ' as ending the first single-quoted string, then "'" as a double-quoted single quote, and then the last ' as a beginning of a new single-quoted string. That'd be</p> <pre><code>sed -i 's/'"'"'ADMIN_USERNAME'"'"','"'"'memcache'"'"'/'"'"'ADMIN_USERNAME'"'"','"'"'u'"'"'/g' /var/www/html/memcache.php </code></pre> <p>You should also be able to do '\'' in place of the ' within the command, for the same reason.</p> <pre><code>sed -i 's/'\''ADMIN_USERNAME\'',\''memcache\''/\''ADMIN_USERNAME\'',\''u\''/g' /var/www/html/memcache.php </code></pre> <p>But really, it'd be better to use an alternative mechanism. I'd suggest defining the source and target strings as variables, and then put those in the sed string.</p> <pre><code>SRC="'ADMIN_USERNAME','memcache'" DST="'ADMIN_USERNAME','u'" sed -i "s/$SRC/$DST/g" /var/www/html/memcache.php </code></pre> <p>That's way more readable, and it makes it easier for you to handle the quoting mess in a sane way with bite-sized chunks. Yay "shell variable contents aren't subject to word expansion unless you force it" knowledge. :)</p> <p>Make sure you don't put a / in the $SRC or $DST variables, though. ;)</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload