0
0
Linux CLIscripting~15 mins

Shell concept (Bash, Zsh) in Linux CLI - Mini Project: Build & Apply

Choose your learning style9 modes available
Basic Shell Scripting with Variables and Loops
📖 Scenario: You are learning how to automate simple tasks in the Linux shell using Bash or Zsh. Imagine you want to keep track of your favorite fruits and print a message for each one.
🎯 Goal: Create a shell script that stores a list of fruits, sets a greeting message, loops through the fruits, and prints a personalized message for each fruit.
📋 What You'll Learn
Create a variable called fruits containing the exact list: apple, banana, cherry
Create a variable called greeting with the exact text: "I love"
Use a for loop with variable fruit to iterate over fruits
Print the message combining greeting and fruit exactly as shown
💡 Why This Matters
🌍 Real World
Shell scripts like this help automate repetitive tasks such as processing lists of files, users, or data entries.
💼 Career
Basic shell scripting is essential for system administrators, developers, and anyone working with Linux servers or automation.
Progress0 / 4 steps
1
Create the list of fruits
Create a variable called fruits and assign it the exact string: "apple banana cherry"
Linux CLI
Need a hint?

Use quotes to assign multiple words to a variable in shell.

2
Add a greeting message
Create a variable called greeting and assign it the exact text: "I love"
Linux CLI
Need a hint?

Remember to use quotes for strings with spaces.

3
Loop through the fruits
Use a for loop with variable fruit to iterate over fruits and inside the loop print the message combining greeting and fruit separated by a space.
Linux CLI
Need a hint?

Use for fruit in $fruits; do ... done and echo to print.

4
Run the script and see the output
Run the script and print the output. The output should show each fruit with the greeting on its own line.
Linux CLI
Need a hint?

Run the script in your shell or use bash script.sh if saved in a file.