Korn Shell (ksh)
History
The Korn Shell (ksh) was developed by David Korn at AT&T Bell Laboratories in the early 1980s. It was designed to be a comprehensive, high-performance shell that combined the best features of the Bourne Shell (sh) and the C Shell (csh). Korn Shell is known for its scripting capabilities, performance, and compatibility with both Bourne and C Shell scripts.
Features
Scripting: Supports advanced scripting capabilities.
Command History: Allows users to recall and edit previous commands.
Job Control: Manages multiple processes within a single shell session.
Aliases: Creates shortcuts for frequently used commands.
Arithmetic Operations: Supports built-in arithmetic operations.
Arrays: Provides support for one-dimensional arrays.
Basic Commands
Navigation
pwd: Print the current working directory.cd [directory]: Change the current directory to the specified directory.ls: List the contents of the current directory.
File and Directory Management
touch [filename]: Create a new empty file.mkdir [directory]: Create a new directory.rm [filename]: Remove a file.rmdir [directory]: Remove an empty directory.cp [source] [destination]: Copy a file or directory.mv [source] [destination]: Move or rename a file or directory.
Scripting
Basic Script
Variables
Conditional Statements
Loops
For Loop
While Loop
Functions
File Operations
Creating a File
Reading a File
Deleting a File
Example: Backup Script
This script compresses the contents of the source directory into a tar.gz file and saves it in the backup directory with a timestamp.