代码改变世界

Shell Scripting 笔记

2020-10-17 17:27  AndrewCja  阅读(124)  评论(0编辑  收藏  举报

Shell Scripting Tutorial

 

Variables in the Bourne shell do not have to be declared, as they do in languages like C.

But if you try to read an undeclared variable, the result is the empty string.

In order to receive environment changes back from the script, we must source the script - this effectively runs the script within our own interactive shell, instead of spawning another shell to run it.
. ./my.sh (.space./my.sh)

touch "${USER_NAME}_file"

The "." dot before the name of the library.sh is not a typo; it tells the calling shell not to spawn another shell for library.sh, so that its functions (and variables) become available to the calling shell.

Reference for keywords that are not search engine friendly