Miscellaneous Programming Features

The next sections cover some miscellaneous programming features.

The . Command

The . command reads in a complete file, then executes the commands in it as if they were typed in at the prompt. This is done in the current shell, so any variable, alias, or function settings stay in effect. It is typically used to read in and execute a profile, environment, alias, or functions file. Here the .profile file is read in and executed:

						$ . .profile
					

The following example illustrates the difference between executing files as Korn shell scripts and reading/executing them using the . command. The .test file sets the variable X:

						$ cat .test
						X=ABC
					

When the .test file is executed as a Korn shell script, variable X is not ...

Get Korn Shell: Unix and Linux Programming Manual, Third Edition, The now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.