课程: Linux: Bash Shell and Scripts

今天就学习课程吧!

今天就开通帐号,24,700 门业界名师课程任您挑!

Solutions: Scripts with exported variables, sourcing, and echo

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

课程: Linux: Bash Shell and Scripts

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…

内容