Sed Fails to store the result into a variable

Dimitrios Desyllas

I try to put the result value of this command:

sed "s/\$ip/${ip}/g" xdebug.conf

Provided from this file xdebug.conf:

zend_extension = xdebug.so
xdebug.remote_enable = 1
xdebug.remote_host = $ip
xdebug.remote_port = 9091
xdebug.max_nesting_level = 1000
xdebug.remote_handler=dbgp
xdebug.remote_mode=req
xdebug.remote_autostart=true
xdebug.remote_log=xdebug.log

Into a variable named $conmfiguration.

In order to achieve that I try:

ip="125.12.22.1"
$configuration=$(sed "s/\$ip/${ip}/g" xdebug.conf)

But I get the following weird result:

=zend_extension: command not found

DO you know why that happens?

ilkkachu

Here,

$configuration=$(sed "s/\$ip/${ip}/g" xdebug.conf)

both $configuration and $(sed ...) get expanded. If the variable is empty, you get

=zend_extension = xdebug.so ...

The first word is taken as a command, and the rest as arguments to it. The shell tries to find =zend_extension, fails, and complains.

Remove the $ from the left-hand side of the assignment, then the assignment works. This outputs foo bar:

var=$(echo foo bar)
echo $var

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

store the result of xpath into an variable to assist in future query

From Dev

Cut of word from a string and store result to variable

From Dev

How to store query result (a single document) into a variable?

From Dev

How to store in a variable an echo | cut result?

From Dev

Cannot store result into variable SQL

From Dev

Store column result in variable

From Dev

Is it okay to store the result of a JQuery selector in a variable?

From Dev

Store result of a for loop in Perl as a single variable

From Dev

Grep a variable and store the result in a vector in R

From Dev

Store function result into variable

From Dev

store a result of a command into a variable using csh

From Dev

Store a sql query result in pentaho variable

From Dev

store result of select query into array variable

From Dev

How to store sed result in variable in tcsh

From Dev

Store result of array.sort in another variable

From Dev

Store output of sed with command substitution in it into a variable

From Dev

How to assign result of sed to variable

From Dev

How to assign result of sed to variable

From Dev

Assign sed result to a variable

From Dev

Store the result of a command in a variable

From Dev

Store the assert failure result in a variable

From Dev

Store the result of a Dynamic Query in a variable

From Dev

store into variable a sudo result

From Dev

Store into variable result of function VBA

From Dev

Store cmd Find result to a variable

From Dev

Store function result into variable

From Dev

How to store sed result in variable in tcsh

From Dev

Store Result of SVN Command in Variable

From Dev

How to store a query result in a variable

Related Related

HotTag

Archive