Few Basic exmaple of Bash Script.
- Executable Command: To Make the file executable, you need to run below command:
chmod +x filename.sh
and then run
sudo ./filename.sh
Few Examples are below
- PRINT/ECHO Command
- VARIABLES DECLARATION
- USER INPUT COLLECT
- IF STATEMENT
- IF ELSE STATEMENT
- ELSE-IF STATEMENT
- SIMPLE FOR LOOP
- COMPARISON
- FILE EXIST OR NOT
- CASE STATEMENT
- RENAME FILES USING LOOP
- WHILE LOOP
- SIMPLE ARRAY
- SIMPLE FUNCTION
- FUNCTION AND PARAMS
- CREATE FOLDER
- WRITE FILE
- ARITHEMATIC OPERATOR
- BINARY TO DECIMAL CONVERSION
- DECIMAL TO BINARY CONVERSION
- LOWER CASE CONVERSION
- SIMPLE CALCULATOR
- NESTED IF CONDITION- SIMPLE STUDENT RESULT
- PRIME NUMBER CHECK
Few Bash Script books
The Linux Command Line by William Shotts
Advanced Bash Scripting Guide by Mendel Cooper