From the course: Linux: Bash Shell and Scripts

Unlock the full course today

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

Challenges: Scripts with exported variables, sourcing, and echo

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

From the course: Linux: Bash Shell and Scripts

Start my 1-month free trial

Challenges: Scripts with exported variables, sourcing, and echo

- [Instructor] Let's write some Bash scripts. So for the first one, make sure you've got the shebang for it and have it print the value of variable A, maybe with a little message, the value of A is, and then the value thing. Now run your script without having set variable A. Then on the command line, say A=1 and run your script again and see what it prints. Then, do export A=2 on the command line and run your script again and see what it prints. Think about what should it print? Now let's write a script, let's call it set.sh and have it set the variable A to be the value 10. Then on the command line, say A=5 and run your script that prints A to see it print A. We want to be sure that A has been exported. What's it going to print? Now on the command line, set A=5, A is exported and in your script that prints A, before printing A, source set.sh. Remember the source set.sh sets A to 10, so we should see that the script prints A as 10. Now this time on the command line, again set A=5, but…

Contents