Reputation: 2342
(cd /home/sharan/code/darknet; darknet_result=$(git remote -v | grep $SD_Darknet))
echo $darknet_result
The result for $daknet_result
is just an empty space . How would I get the varaible to be assigned.
Upvotes: 0
Views: 44
Reputation: 85757
darknet_result=$(cd /home/sharan/code/darknet; git remote -v | grep "$SD_Darknet")
The problem in your code is that (
)
starts a new subshell, so any variable assignments there are not visible in the parent shell.
Upvotes: 2