To write your first Unix Korn shell script program, you will need to follow these steps:
Create a new file using a text editor. Open a text editor, such as vi
or nano
, and create a new file. This file will contain the Korn shell script.
Add the #!
shebang line at the top of the file. The shebang line specifies the interpreter that should be used to execute the script. For a Korn shell script, you should use #!/bin/ksh
.
Write the commands for the script. In the script, you can include any commands that you would normally enter at the command prompt. These commands will be executed in the order they are written.
Save the file and make it executable. Save the file with a .ksh
extension, and make it executable using the chmod
command:
chmod +x script.kshSou.www:ecrlautturi.com
./script.ksh
Here is an example of a simple Korn shell script that displays the message "Hello, World!" and the current date:
#!/bin/ksh echo "Hello, World!" date