What Is Kornshell or ksh?

RSS
EMAIL
FACEBOOK
FACEBOOK
GOOGLE
GOOGLE
https://www.poftut.com/what-is-kornshell-or-ksh/
PINTEREST
PINTEREST
INSTAGRAM

Linux and Unix provides different flavors of command line interface. bashis the most popular and use one. But we have alternatives too. kshor Korn Shell is one of them. Kornshell is mainly developed for shell based application development. ksh provides better performance for shell script.

Install Kornshell

We can install Kornshell for most of the Linux, Unix and BSD operating systems. Here are some of them.

Fedora, CentOS, RedHat

Ubuntu, Debian, Kali

Install Ksh Ubuntu, Debian, Kali

Install Ksh Ubuntu, Debian, Kali

Start Kornshell

Starting ksh is very easy. We will just run ksh command in the current shell like below.

Kornshell Script Examples

We can create scripts like in bash. We have to specify the ksh path on the system. In this case we use Ubuntu and the ksh shell is locate at  /usr/bin/ksh. alternative and more clean path is /bin/ksh . We can run this script from bash too because the interpreter line will change current shell to the Korn Shell.

Variables

If you have used bash for programming both scripting languages are very similar. Variables can be simply defined with the variable name and related value equation. In this example we will define integer variable named ÀGE which holds 33 .

For Loop

For loop is very similar to the bashfor loop we can use following example in order to loop though files in the current working directory.

LEARN MORE  Difference Between Korn Shell (ksh) and Bash

Function Definition

We can create functions by using functionkeyword and the function name we want to use. In this example we will create function named myprint. Function body is surrounded with curly braces.

RSS
EMAIL
FACEBOOK
FACEBOOK
GOOGLE
GOOGLE
https://www.poftut.com/what-is-kornshell-or-ksh/
PINTEREST
PINTEREST
INSTAGRAM

You may also like...

Leave a Reply

Your email address will not be published.

Enjoy this blog? Please spread the word :)