O'Reilly logo

Korn Shell: Unix and Linux Programming Manual, Third Edition, The by Anatole Olczak

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Executing Korn Shell Scripts

Let's make a Korn shell script out of the print Hello world command by putting it into a file like this:

					$ print "print Hello world" >prhello
				

Before Korn shell scripts can be executed, they must be made executable by setting the execute and read bits with the chmod command:

					$ chmod 755 prhello
				

or

					$ chmod +rx prhello
				

Assuming that the current directory is in the search path $PATH, prhello can now be executed by simply invoking it by name:

					$ prhello
					Hello world
				

Korn shell scripts can also be executed by invoking them as the first argument to ksh:

					$ ksh prhello
					Hello world
				

Now we can use prhello like any other command. The output can be directed to a file:

					$ prhello >p.out
					$ cat p.out
					Hello world
				

It can ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required