From the course: Linux Bash Shells and Scripts: Streamlining Tasks and Enhancing Workflows with Automation

Unlock this course with a free trial

Join today to access over 24,900 courses taught by industry experts.

Solution: Exported variables, sourcing, and echo

Solution: Exported variables, sourcing, and echo

(upbeat electronic music) (upbeat electronic music ends) - [Instructor] Let's look at solutions to these challenges. So I'm in the lab exercises, ch01 directory, still, and you should have these files, and they correspond to the questions we have. And let's take a look. So the first thing we were supposed to do is write a bash script with the shebang inside that prints variable A. So we've got something that does that. And then it says, you know, give it execute permissions. So we could do change mod plus X prA.sh. Then it says, run your script without defining or setting a variable in your shell. So I'm going to unset A, in case I had one, to make sure it's not set. And then we're going to run it. A is, and it doesn't have a value, so it just says nothing. Then it says, run it again after setting A equals one on the command line. So we'll say, A equals one and just to check, yeah, it's one. Now, we run the script again. Still, it doesn't print anything because our script didn't get a…

Contents