Thursday, May 9, 2013

Korn Shell scripting intro

I recently started writing korn shell scripts here and there and below is some useful info on how to get started. I use vi editor for creating files:
vi myscript.ksh
Korn shell scripts usually have extension ksh The first line of the script should always be:
After the file has been created, one needs to give it execute permissions so that the file becomes runable:
chmod 755 myscript.ksh
Now the script can be executed as follows:
if the script name or path has spaces in it, it needs to be wrapped in double quotes
"C:\My Documents\My Scripts\myscript.ksh"
The escape character for ksh scripts is a (\) backslash. For example if you want to escape a dollar sign ($) inside your script, instead of writing
select * from v$database;
select * from v\$database;
(#) pound sign is used for comments and print and echo commands are used to output text to a sceen

No comments:

Post a Comment