Shell Programming Notes
1. What is Shell?
Shell is a program that acts as an interface between the user and the operating system. It takes
commands from the user and executes them.
2. Shell Scripting
A shell script is a file containing a series of UNIX/Linux commands. It is used to automate tasks.
3. Shell Script Basics
- File extension: .sh
- First line: #!/bin/bash
- Run script using: sh [Link]
4. Shell Variables
Variables store data. No space is allowed around '=' sign.
Example: name="Anju"
5. Command Line Arguments
$1, $2 are arguments
$# shows number of arguments
$@ shows all arguments
6. If Statement
Used for decision making.
Syntax:
if [ condition ]
then
commands
fi
7. Loop
Loops are used to repeat tasks.
Types: for loop, while loop
8. Return
Return statement sends status value from function.
9. Basic UNIX Commands
ls – list files
pwd – present directory
cd – change directory
cp – copy files
mv – move files
rm – delete files
cat – display file content
mkdir – create directory