0

This question already has an answer here:

~$ cat ~/forked_sh.sh
#/bin/sh
echo THis_is_return
sleep 2;


~$ socket=wlan0
~$ echo $socket
wlan0
~$ mystring_$socket=.`/forked_sh.sh`
mystring_wlan0=THis_is_return: command not found

I was expecting that it will assign, but the bash running as whole as 1 string in place of $ a=sfkjsdf

marked as duplicate by l0b0, Jeff Schaller, G-Man, Anthon, GAD3R Apr 2 '17 at 8:34

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • 2
    are your first backtick and the '.' reversed? – user208145 Apr 1 '17 at 21:46
  • 1
    As noted by @user208145, you have a typo. you need mystring_$socket='./forked_sh.sh' (with backticks). Or better: mystring_$socket=$(./forked_sh.sh) – Stephen Rauch Apr 1 '17 at 21:55
  • Welcome to Unix & Linux Stack Exchange. It would appear that you have accidentally created two accounts. You should use the contact form and select “I need to merge user profiles” to have your accounts merged. In order to merge them, you will need to provide links to the two accounts.  For your information, they are unix.stackexchange.com/users/223919/kapil-dev and unix.stackexchange.com/users/223922/kapil-dev. You’ll then be able to edit, comment on, and accept answers to this question. – G-Man Apr 2 '17 at 0:12
0

I found my self using eval xyz

  • 1
    eval is almost always the wrong answer -- there are too many ways for it to go wrong. In this case, declare would work, and be much safer. – Gordon Davisson Apr 2 '17 at 0:56

Not the answer you're looking for? Browse other questions tagged or ask your own question.