Shell Scripting Challenge
Shell scripting in Bash is an essential skill for any Linux user, especially for DevOps professionals. It allows for automating tasks, managing systems efficiently, and performing repetitive tasks with ease. In this guide, we will walk through some fundamental concepts of shell scripting with practical tasks to solidify your understanding.
Comments
Comments in bash scripts are used to add explanatory notes or disable certain lines of code. This is especially useful for documenting your code, making it easier for others (and yourself) to understand what each part of the script does.
Script with Comments
Echo
The echo
command is used to display messages on the terminal. It's a basic but powerful way to interact with the user and display information.
Script Using Echo
Variables
Variables in bash are used to store data, which can then be referenced by their name. This is useful for making scripts dynamic and reusable.
Script Declaring Variables
Using Variables
Once variables are declared, they can be used to perform various tasks. Here, we will create a script that takes two variables (numbers) as input and prints their sum.
Script Using Variables
Using Built-in Variables
Bash provides several built-in variables that hold useful information about the system and the script itself. We will create a script that utilizes at least three different built-in variables to display relevant information.
Script Using Built-in Variables
Wildcards
Wildcards are special characters used to perform pattern matching when working with files. They are useful for listing, moving, or manipulating files that match a specific pattern.
Script Using Wildcards
Subscribe to my newsletter
Read articles from Rajat Chauhan directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
Rajat Chauhan
Rajat Chauhan
Rajat Chauhan is a skilled Devops Engineer, having experience in automating, configuring, deploying releasing and monitoring the applications on cloud environment. • Good experience in areas of DevOps, CI/CD Pipeline, Build and Release management, Hashicorp Terraform, Containerization, AWS, and Linux/Unix Administration. • As a DevOps Engineer, my objective is to strengthen the company’s applications and system features, configure servers and maintain networks to reinforce the company’s technical performance. • Ensure that environment is performing at its optimum level, manage system backups and provide infrastructure support. • Experience working on various DevOps technologies/ tools like GIT, GitHub Actions, Gitlab, Terraform, Ansible, Docker, Kubernetes, Helm, Jenkins, Prometheus and Grafana, and AWS EKS, DevOps, Jenkins. • Positive attitude, strong work ethic, and ability to work in a highly collaborative team environment. • Self-starter, Fast learner, and a Team player with strong interpersonal skills • Developed shell scripts (Bash) for automating day-to-day maintenance tasks on top of that have good python scripting skills. • Proficient in communication and project management with good experience in resolving issues.