0
0
Bash Scriptingscripting~10 mins

String variables in Bash Scripting - Mini Project: Build & Apply

Choose your learning style9 modes available
String variables
📖 Scenario: You are writing a simple bash script to store and display a greeting message. This is like writing a note to yourself that you want to see later.
🎯 Goal: Create a string variable in bash, assign a greeting message to it, and then print it to the screen.
📋 What You'll Learn
Create a string variable named greeting with the exact value Hello, welcome to bash scripting!
Create a variable named name with the exact value Friend
Use string concatenation to create a new variable personal_greeting that combines greeting and name with a space in between
Print the value of personal_greeting to the screen
💡 Why This Matters
🌍 Real World
Storing and manipulating text messages in scripts is common for creating user prompts, logs, and notifications.
💼 Career
Understanding string variables is a basic skill for writing shell scripts that automate tasks and communicate with users.
Progress0 / 4 steps
1
Create a string variable
Create a string variable called greeting and assign it the exact value Hello, welcome to bash scripting!
Bash Scripting
Need a hint?

Use the syntax variable_name="value" to create a string variable in bash.

2
Add a name variable
Create a string variable called name and assign it the exact value Friend
Bash Scripting
Need a hint?

Remember to use double quotes around the string value.

3
Combine strings into a new variable
Create a new variable called personal_greeting that combines greeting and name with a space between them using string concatenation
Bash Scripting
Need a hint?

Use variable="$var1 $var2" to join strings with a space in bash.

4
Print the combined greeting
Print the value of the variable personal_greeting to the screen using echo
Bash Scripting
Need a hint?

Use echo "$variable" to print a variable's value in bash.