hands-on lab

Practicing Shell Scripting Fundamentals

Beginner
Up to 45m
2,618
Get guided in a real environmentPractice with a step-by-step scenario in a real, provisioned environment.
Learn and validateUse validations to check your solutions every step of the way.
See resultsTrack your knowledge and monitor your progress.
Lab description

Shell scripts contain a series of commands that are executed by an interpreter. Shell scripts are easy to use and can help developers automate frequently performed operations and run sequences of commands as a single command. Sharing your scripts with team members is also possible due to the portable nature of these scripts.

In this lab, you will use fundamental shell scripting commands and tools to write a shell script. The commands used in this lab have been covered in the Shell Scripting, Succinctly course. References to the specific lessons of the course will be provided throughout the lab steps.

Expected outputs for each lab step are provided in the script comments.

The Linux commands and tools referenced in this lab are:

  • Shell Variables
  • Command Line Arguments: $1, $@
  • Test Cases: []
  • File Operators: -s, -e
  • Conditional Statements: if, elif, else
  • For Loops: for, do
  • echo
  • vim, nano, or emacs

Learning Objectives

Upon completion of this lab, you will be able to:

  • Declare and utilize variables in a shell script
  • Combine tests with if/else statements to run conditional commands
  • Iterate through command-line arguments with a for loop

Intended Audience

  • Those beginning to work with Linux
  • Those seeking practice with basic shell scripting
  • Software Engineers
  • DevOps Engineers

Prerequisites

Familiarity with basic shell scripting and working with a Linux code editor will be beneficial. Refer to the following courses to fulfill the prerequisite:

Updates

July 6th, 2022 - Made check one accepting of whitespaces and other functional permutations of solutions

About the author
Avatar
Jun Fritz, opens in a new tab
Cloud Labs Developer
Students
39,972
Labs
108
Courses
1
Learning paths
6

Jun is a Cloud Labs Developer with previous experience as a Software Engineer and Cloud Developer. He holds the AWS Certified Solutions Architect and DevOps Engineer Professional certifications. He also holds the AWS Certified Solutions Architect, Developer, and SysOps Administrator Associate certifications. 

Jun is focused on giving back to the growing cloud community by sharing his knowledge and experience with students and creating engaging content. 

Covered topics
Lab steps
Accessing the Amazon Linux 2 Terminal
Modifying Your Lab Shell Script
Declaring and Using Shell Variables
Incorporating Tests with Conditional Statements
Looping Through Command Line Arguments