I would like to execute commands inside a shell script and store in a variable, but it is opening a new shell which I do not want. Is there any way to correct this? Here is my script.
#!/bin/bash
V1=`<any_command>` #The shell should not open a new shell
V2=`<another_command>` #The shell should not open a new shell
I can execute the shell script like below to execute on same shell:
. ./Script.sh
But if there are commands inside shell script to be stored in variable and for that I use
V1=`<any_command>`
Which still opens a new shell, which I do not want.
<any_command>
? It seems like your problem lies in that you're executing inside your ticks. – Zachary Brady Nov 23 '16 at 14:23