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.kshKorn shell scripts usually have extension ksh The first line of the script should always be:
#!/usr/bin/kshAfter the file has been created, one needs to give it execute permissions so that the file becomes runable:
chmod 755 myscript.kshNow the script can be executed as follows:
./myscript.kshif 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;use
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