This repository is designed to provide a foundational understanding of shell scripting. Below, you'll find details about the key scripts in the repository and how you can use them to enhance your skills.
Before diving into these scripts, ensure you have the following:
- A Unix-based operating system or a Linux distribution.
- A terminal or shell environment.
- Basic knowledge of command-line operations.
- A text editor (e.g.,
vim,nano, orVisual Studio Code).
- Purpose: Prints a simple greeting message.
- Learning Objective: Understand the basics of using
echoto display output in the terminal. - Key Concepts:
- Using the
echocommand. - Running a basic shell script.
- Using the
- Purpose: Demonstrates the use of
ifstatements in shell scripting. - Learning Objective: Learn conditional logic to make decisions in scripts.
- Key Concepts:
- Syntax of
if,then,else, andfi. - Checking conditions using test brackets
[].
- Syntax of
- Purpose: Shows how to pass and handle arguments in a shell script.
- Learning Objective: Understand how to use positional parameters like
$1,$2, etc. - Key Concepts:
- Accessing script arguments.
- Using arguments to make scripts more dynamic.
- Purpose: Teaches how to capture and process user input interactively.
- Learning Objective: Learn to use the
readcommand for interactive scripts. - Key Concepts:
- Capturing user input.
- Using input variables in the script.
- Purpose: Introduces variables and their usage in shell scripts.
- Learning Objective: Understand how to declare, assign, and use variables.
- Key Concepts:
- Variable declaration and assignment.
- Using variables to store and manipulate data.
- Purpose: Demonstrates the use of
forloops in shell scripting. - Learning Objective: Learn how to iterate over a list of items and a range of numbers.
- Key Concepts:
- Using
forloops to iterate over a list of items. - Using
forloops to iterate over a range of numbers.
- Using
- Purpose: Demonstrates the use of
whileloops in shell scripting. - Learning Objective: Learn how to iterate with a condition and use a counter.
- Key Concepts:
- Using
whileloops to iterate with a condition. - Using
whileloops with a counter.
- Using
- Purpose: Demonstrates the use of functions in shell scripting.
- Learning Objective: Learn how to define and call functions with and without arguments.
- Key Concepts:
- Defining functions without arguments.
- Defining functions with arguments.
- Calling functions.
-
Clone the Repository:
git clone <repository_url> cd shell-scripting-fundamentals
-
Make the Scripts Executable:
chmod +x *.sh -
Run the Scripts:
./hello.sh ./ifStatement.sh ./passArgumentsToaBash.sh ./readUserInput.sh ./variable.sh ./forLoop.sh ./whileLoop.sh ./functions.sh
- Modify the scripts to experiment with different inputs and scenarios.
- Add comments to each script to explain each line in your own words.
- Practice combining the concepts learned from multiple scripts into a single, more complex script.
Happy scripting! 🚀