Simple Script

Most of this chapter deals with how the Korn shell interacts with Unix , but to briefly explain the scripting concept a very simple example is provided. First of all, ls is a Unix command that lists the name of the files in the current directory, and print is a Korn shell command that displays its argument. Using your favorite Unix editor, enter the following text into a file called simple_script.ksh:

					print "Here are the current files:"
					ls
				

Assuming that you are using the Korn shell, have execute permission in your default umask and that you have the current path included in your environment (this will also be covered later!), run the script like this:

					$ simple_script.ksh
					Here are the current files:
					simple_script.ksh /tmp report.txt ...

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

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.