Skip to content

This is my repository which consists of various bash scripts that I developed while learning Bash

Notifications You must be signed in to change notification settings

DEV270201/Bash_Scripting

Repository files navigation

Bash Scripting

A collection of my Bash scripts developed to practice automation, system monitoring, and CLI argument handling.


📁 Script Directory

System Monitoring & Analysis

  • analyze_memory.sh: Reports the current memory and disk usage of the machine.
  • running_rss_total.sh: Analyzes the Resident Set Size (RSS) memory consumed by currently active processes.
  • analyze_logs.sh: A tool to analyze logs.
    • Usage: ./analyze_logs.sh <logfile_path>

Logic & Syntax Practice

  • cli_args.sh: Demonstrates how to handle and process command-line arguments.
  • positional_args.sh: Showcases the use of the shift operator to navigate positional parameters.
  • functions.sh: Examples of how to define and invoke reusable functions within a script.

Automation & Dev Ops

  • run_postgres_container.sh: Orchestrates Docker containers. It checks for an existing Postgres container; if found, it starts it; otherwise, it pulls the image and runs a new instance.
  • move_shell_files.sh: Scans a source directory for .sh files and moves them to a target directory. It includes logic to prevent overwriting existing files.
  • cloudfront_download_files.sh: Network testing script that fetches files from an AWS CloudFront edge location and records the Time to First Byte (TTFB) to test cache performance.
  • practice.sh: General scratchpad for testing new snippets and logic.

🚀 How to Use

  1. Clone the repo:
    git clone https://github.com/DEV270201/Bash_Scripting.git
  2. Grant execution permissions:
    chmod +x *.sh
  3. Run a specific script within the same directory:
    ./analyze_memory.sh

🛠 Lessons Learned

  • Core Fundamentals: Mastered the use of for/while loops, arithmetic operations using $((...)), and complex if/elif/else conditional logic.
  • Positional Parameters: Understood how to use $1, $@, and the shift operator to create flexible CLI tools that handle multiple arguments.
  • Stream Redirection: Learned about file descriptors (1 for stdout, 2 for stderr) and how to redirect or silence outputs using > /dev/null 2>&1.
  • Text Processing & Utilities: Gained hands-on experience with powerful CLI tools like awk and sed for text transformation, grep for searching, and find for file management.
  • System Metrics: Used native tools like free, df, and ps to parse and display system health and resource consumption.
  • Containerization: Automated environment setups by wrapping Docker lifecycle commands (pull, run, start) within Bash logic.
  • Network Latency: Studied AWS Edge performance by measuring TTFB (Time to First Byte) via network requests.

About

This is my repository which consists of various bash scripts that I developed while learning Bash

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages