Z Shell (zsh)
History
The Z Shell (zsh) was created by Paul Falstad in 1990. It was designed to be an extended Bourne Shell (sh) with many improvements, including features from other shells like the Korn Shell (ksh) and the C Shell (csh). Over time, zsh has become popular for its powerful scripting capabilities, user-friendly features, and extensive customization options.
Features
Command Line Editing: Supports advanced command line editing with Emacs and Vi modes.
Tab Completion: Provides powerful and customizable tab completion for commands, file names, and more.
Scripting: Supports advanced scripting capabilities.
Job Control: Manages multiple processes within a single shell session.
Aliases: Creates shortcuts for frequently used commands.
Prompt Customization: Allows extensive customization of the shell prompt.
History Mechanism: Enables users to recall and edit previous commands.
Globbing: Supports advanced pattern matching for file names.
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.