Week 2: My Shell Scripting Journey ๐Ÿš€

Pranab NandiPranab Nandi
3 min read

As I continue my DevOps learning path, week 2 focused on mastering Shell Scripting, a powerful tool in automating tasks and managing system operations. Followed an excellent tutorial by TrainWithShubham: ๐ŸŽฅ Shell Scripting in One Shot | 3 Live Projects For DevOps (Hindi). From variables to cronjobs, Iโ€™ve encountered new challenges, but also discovered ways to solve them, all while creating a solid foundation for the upcoming weeks.


๐Ÿ“š Topics I Learned

During this week, I dived into the following topics:

  1. Variables
    I learned how to define and manipulate variables within
    Bash scripts.

  2. Arguments
    Handling user inputs and positional parameters using command-line arguments.

  3. Conditionals
    I explored how to control the flow of execution with if, else, and elif conditions.

  4. Loops
    Implemented different types of loops: for, while, and until loops to automate repetitive tasks.

  5. Functions
    I structured my scripts better by creating reusable functions.

  6. Error Handling
    Understanding how to handle errors effectively by checking command success and failure.

  7. AWS CLI
    I integrated basic AWS CLI commands into my scripts for cloud automation.

  8. Makefiles
    Automated build and execution tasks with Makefiles, making scripts more modular and maintainable.

  9. Backup
    I created scripts for systematically backing up files and directories.

  10. Rotation
    Managed storage space effectively by implementing backup rotation in my scripts.

  11. Cronjobs
    Set up and configured cronjobs to schedule automatic execution of tasks.


๐Ÿ›  Challenges I Faced

1. Learning Shell Scripting and Makefile Syntax

At first, I found the syntax of Shell scripting and Makefiles quite overwhelming, especially with the different conventions and structures.

2. Setting Up Cronjobs

Another challenge I faced was configuring cronjobs correctly. I had difficulty ensuring the scripts ran at the specified times.

3. Pre-made Projects in Tutorials

The tutorials I followed used pre-made projects, which made it hard to connect the individual concepts I was learning with practical, standalone examples.


โœ… How I Solved These Challenges

1. Continuous Practice

Wrote dozens of tiny scripts and Makefiles, ran bash -n and make -n for syntax checks, and gradually internalized the differences between tabs/spaces and quoting rules.

2. Debugging Cronjobs

Added cd /full/path at the start of each script, replaced bare commands with their absolute paths (e.g., /usr/bin/zip), and redirected logs (>>/var/log/backup.log 2>&1).

Added echo "DEBUG: reached backup step" statements and then verified execution via grep CRON /var/log/syslog.

3. Starting with Simpler Scripts

Rather than trying to dive into pre-built projects, I took the approach of writing simpler scripts to understand each topic individually. Iโ€™ll integrate these simpler scripts into larger projects as I go.


๐Ÿ“‚ Repository

You can find all the scripts and files I wrote during this week in my GitHub repository:
๐Ÿ”— My Shell Scripting Journey โ€” GitHub

Feel free to check them out, provide feedback, or suggest improvements! Iโ€™d love to hear your thoughts.


This week was full of both challenges and breakthroughs. Shell scripting has already proven to be an essential tool in my DevOps toolkit, and Iโ€™m looking forward to diving deeper in the coming weeks. Stay tuned for more updates on my journey! ๐Ÿš€

0
Subscribe to my newsletter

Read articles from Pranab Nandi directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Pranab Nandi
Pranab Nandi