0

I have one script named a.sh from where I'm calling b.sh and passing some parameters from a.sh to b.sh . After b.sh is completed I'm exporting some variables from b.sh and I want to echo it from a.sh . I'm using export command in b.sh but I when I'm doing an echo command It is not showing anything in a.sh .

#b.sh
x=1
#some function is there
export $x

#a.sh
sh b.sh
echo "X value is : $x"
#output
# X value is :
Rangan Roy
  • 15
  • 6
  • You want to source instead of executing: [What is the difference between `sh` and `source`?](http://stackoverflow.com/q/13786499/1983854). Also, you `export x`, using `x` instead of `$x`. – fedorqui Jan 26 '17 at 11:27
  • But when I'm using source it is saying that file b.sh not found but it is there in my directory – Rangan Roy Jan 26 '17 at 12:08
  • Describe what exact steps you are taking, since `source b.sh` from the same directory should work without any problem. – fedorqui Jan 26 '17 at 12:12
  • It worked just I've mentioned the entire path like /full_path/b.sh – Rangan Roy Jan 26 '17 at 12:24

0 Answers0