课程: Linux: Bash Shell and Scripts
今天就学习课程吧!
今天就开通帐号,24,700 门业界名师课程任您挑!
Challenges: Scripts with exported variables, sourcing, and echo - Linux教程
课程: Linux: Bash Shell and Scripts
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…
随堂练习,边学边练
下载课堂讲义。学练结合,紧跟进度,轻松巩固知识。
内容
-
-
-
Exploring the Bash documentation1 分钟 57 秒
-
Setting the script interpreter and permissions6 分钟 29 秒
-
(已锁定)
Time commands and set variables9 分钟 10 秒
-
Bash startup4 分钟 28 秒
-
(已锁定)
Sourcing and aliasing with bash5 分钟 34 秒
-
(已锁定)
Displaying text with the echo command4 分钟 10 秒
-
(已锁定)
Challenges: Scripts with exported variables, sourcing, and echo2 分钟 6 秒
-
(已锁定)
Solutions: Scripts with exported variables, sourcing, and echo4 分钟 20 秒
-
-
-
-
-