Posts

Showing posts from June, 2011

Dot operator in Scripting.

Using the Unix Dot (.) Operator to Run a Shell Script in the Current Shell In unix, there is the dot operator. The syntax is a dot (period), followed by a space, and followed by a shell script: . script Why would you use the dot operator?   Normally, when you run a shell script, it executes in a child shell. Once the script completes, the child shell goes away and you are returned to the command prompt on the original shell. This means that the   scope   of the script doesn't apply to the invoking shell. In other words, if your script changed the directory or set some variables, those changes won't be reflected after the script ends. Using a dot space in front of the script means that the scope of the script is the same as the invoking shell. For example, let's say that you are currently in the /usr directory and you run the script   go_tmp , which changes the directory to /tmp. If you run   go_tmp   then, after the script ends, you will still...