Welcome to the Shell Script Examples repository! This repository contains simple and beginner-friendly shell scripts to help newcomers get started with shell scripting.
This repository is designed to introduce beginner-level shell scripts. Each script is focused on a specific concept or functionality to help new learners understand the basics of shell scripting.
To run these shell scripts on your local machine, you'll need a Unix-based system (like Linux or macOS) or a Windows system with a bash shell (e.g., using Git Bash or Windows Subsystem for Linux).
Each script in this repository covers a fundamental topic or operation in shell scripting. Here's a brief overview of each one:
- addition-in-for-loop.sh - Demonstrates how to perform addition using a
for
loop. - armstrong.sh - Checks if a number is an Armstrong number.
- average-of-three.sh - Calculates the average of three numbers.
- calc.sh - A basic calculator script that performs addition, subtraction, multiplication, and division.
- even-odd-in-for.sh - Determines if numbers in a loop are even or odd.
- even-odd.sh - Simple script to check if a number is even or odd.
- facto-while.sh - Calculates the factorial of a number using a
while
loop. - max-in-three.sh - Finds the maximum of three numbers.
- max-in-two.sh - Finds the maximum of two numbers.
- palindrome.sh - Checks if a number is a palindrome.
- posi-neg-zero.sh - Determines if a number is positive, negative, or zero.
- reverse-of-no.sh - Reverses a given number.
- stud-grade.sh - Assigns grades based on marks.
- swap.sh - Swaps two numbers without using a third variable.
- voting-eligible.sh - Checks if a person is eligible to vote based on their age.
To run a script, navigate to the repository folder and execute the script using sh
:
sh script-name.sh
For example, to run the addition-in-for-loop.sh
script, use:
sh addition-in-for-loop.sh
Make sure to give execute permissions if needed:
chmod +x script-name.sh
If you would like to contribute additional beginner-friendly shell scripts or improve the existing ones, feel free to open a pull request. Ensure that the code is well-commented and easy for new learners to follow.