From the course: Linux: Bash Shell and Scripts

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Solutions: Scripts with exported variables, sourcing, and echo

Solutions: Scripts with exported variables, sourcing, and echo - Linux Tutorial

From the course: Linux: Bash Shell and Scripts

Start my 1-month free trial

Solutions: Scripts with exported variables, sourcing, and echo

- [Narrator] Let's look at how to do these scripts, scripts to look at some variables, and some options for echo. So first of all, we want to print out A. So, I've got a little script here. Pretty simple. Right, just says echo A is and then the value of A. Just to make sure we don't have a variable A, we're going to unset it, and we're going to run our script and we got A is nothing. Now, we're going to say A equals one on the command line, and we're going to run again. We didn't export A, so again, in the shell, A doesn't have a value, but now we're going to export A, and when we do it, we're going to give it a new value. A is two. Run the script again. And now the script gets a copy of A because it's exported and it could print out that A is two. We'll tell the script set.sh, that assigns a value to A, A is ten. So we've already exported A, but just to make sure, we'll export it again, and we're going to say, A equal five. We're going to run, set.sh. We're going to echo the value of…

Contents