0
~$ 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

  • 2
    are your first backtick and the '.' reversed? – user208145 Apr 01 '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 01 '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 https://unix.stackexchange.com/users/223919/kapil-dev and https://unix.stackexchange.com/users/223922/kapil-dev. You’ll then be able to [edit], comment on, and accept answers to this question. – G-Man Says 'Reinstate Monica' Apr 02 '17 at 00:12

1 Answers1

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 02 '17 at 00:56