Can you tell me how to write a UNIX korn shell script program? I'm new to UNIX scripting and HP-UX UNIX operating system.
Korn shell scripting under UNIX / Linux can be used to automate lots of stuff. It easy to write a shell script. You must know how to use a text editor such as vi to write a script.
Writing your first Korn shell script
Let us write a shell program to print knowledge is power on screen. Type the following command to open file:
The first line should be as follows:
It is called a shebang. It consists of a number sign and an exclamation point character (#!), followed by the full path to the interpreter such as /bin/ksh. All scripts under UNIX execute using the interpreter specified on a first line.
Next append code as follows:
# A shell script to print message # Written by Tom - Jan/13/2008 print "Knowledge is power"
Save and close the file. At the end your script should look like as follows:
#!/bin/ksh # A shell script to print message # Written by Tom - Jan/13/2008 # ------------------------------ print "Knowledge is power"
Set executable permission
Type the following command to set executable permission:
chmod +x hello.ksh
Run your korn shell script
Type the following command:
Knowledge is powerTwitterFacebookGoogle+PDF versionFound an error/typo on this page? Help us!
- 30 Cool Open Source Software I Discovered in 2013
- 30 Handy Bash Shell Aliases For Linux / Unix / Mac OS X
- Top 30 Nmap Command Examples For Sys/Network Admins
- 25 PHP Security Best Practices For Sys Admins
- 20 Linux System Monitoring Tools Every SysAdmin Should Know
- 20 Linux Server Hardening Security Tips
- Linux: 20 Iptables Examples For New SysAdmins
- Top 20 OpenSSH Server Best Security Practices
- Top 20 Nginx WebServer Best Security Practices
- 20 Examples: Make Sure Unix / Linux Configuration Files Are Free From Syntax Errors
- 15 Greatest Open Source Terminal Applications Of 2012
- My 10 UNIX Command Line Mistakes
- Top 10 Open Source Web-Based Project Management Software
- Top 5 Email Client For Linux, Mac OS X, and Windows Users
- The Novice Guide To Buying A Linux Laptop