≡ Menu

KSH HowTos & Tutorials

Learning the Korn Shell on Linux, OS X, and Unix like operating systems. Topic includes shell script programming, tips, customization, hacks and much more ( rss feed ).

KSH: Import File With Variables and Functions

How do I import variables and functions defined in lib.ksh script to another ksh script called setup.ksh under Linux / Unix like operating systems? How do I execute commands from a file in the current KSH shell?
[click to continue…]

HowTo: Find Out KSH ( Korn Shell ) Version

How do I check ksh version? How do I find out ksh version under UNIX like operating systems?
[click to continue…]

Debian / Ubuntu Linux: Install KornShell (KSH)

I am porting ksh script from Sun/Oracle Unix to Debian / Ubuntu Linux based server hosted on AWS cloud. How do I install ksh (KornShell) in Debian or Ubuntu Linux server? How do I run and test ksh scripts?
[click to continue…]

Linux / UNIX: Change Bash To KSH Shell

How do I change my current login shell from bash to ksh under Linux or UNIX or Apple OS X operating systems?
[click to continue…]

Unix / Linux: Save Output To File

I am new Linux and Unis shell user. In Unix or Linux, how do I save outputs in an external file say data.txt?
[click to continue…]

HowTo: Unix For Loop 1 to 100 Numbers

I want to run a Unix command 100 times using a for loop from 1 to 100. Can you tell me how to take a block of numbers in a loop under KSH or BASH shell?
[click to continue…]

Ksh Read a File Line By Line ( UNIX Scripting )

How do I read a file line by line using KSH shell scripting under UNIX like operating systems?
[click to continue…]

Shell Scripting: If Variable Is Not Defined, Set Default Variable

If var is defined AND NOT EMPTY, use var, otherwise set a default variable under Bash. For e.g. my script needs a parameter for output variable. It can be text or html. I set it as follows in my script

output=$1 # either text or html

However, sometime user forget to pass the parameter to my shell script and my enter logic fails. So how do I set default value to text, if no parameter passed?
[click to continue…]

Shell Script While Loop Examples

Can you provide me a while loop control flow statement shell script syntax and example that allows code to be executed repeatedly based on a given boolean condition?
[click to continue…]

KSH For Loop Array: Iterate Through Array Values

How do I use ksh for loop to iterate thought array values under a UNIX / Linux / BSD operating systems?
[click to continue…]