Shell Scripting

Day 1 of Shell Scripting

Welcome to Day 6 of my DevOps journey! Today marks the beginning of an exciting sub-journey into the world of shell scripting. This is an essential skill for any aspiring DevOps professional, and I couldn’t be more thrilled to share what I’ve learned.

Why Learn Shell Scripting?

Shell scripting is the art of automating tasks in the Unix/Linux shell. It allows us to:

  • Simplify repetitive tasks

  • Create powerful tools for system administration

  • Orchestrate complex workflows

  • Enhance productivity and efficiency

Mastering shell scripting is a stepping stone to effective DevOps practices, as it lays the foundation for automation and scripting workflows.

What I Covered Today

I focused on the basics of shell scripting, progressing up to the concept of arrays. Here’s a detailed breakdown of my learning:

1. Introduction to Shell Scripting

Shell scripting involves writing scripts (text files) containing a sequence of commands to be executed by the shell. I explored the following foundational concepts:

  • What is a Shell? The interface between the user and the operating system.

  • Popular Shells: bash, sh, zsh, etc.

  • Creating a Script:

    • Use a text editor (e.g., nano, vim).

    • Save the script with a .sh extension.

    • Make it executable using chmod +x.

  • Running a Script: Execute it with ./script_name.sh.

2. Basic Shell Script Syntax

I learned the fundamental building blocks of a shell script:

  • Comments: Use # to add comments.

  • Variables: Store and manipulate data.

  • Displaying output: echo.

3. Working with Arrays

Arrays allow storing multiple values in a single variable. I explored:

  • Defining Arrays

  • Accessing Elements

  • Array with key value pair

That’s all from my day 6 update my plan for tomorrow is to learn the control flow, reading input, loop and to create some basic projects.