A collection of my Bash scripts developed to practice automation, system monitoring, and CLI argument handling.
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>
- Usage:
cli_args.sh: Demonstrates how to handle and process command-line arguments.positional_args.sh: Showcases the use of theshiftoperator to navigate positional parameters.functions.sh: Examples of how to define and invoke reusable functions within a script.
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.shfiles 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.
- Clone the repo:
git clone https://github.com/DEV270201/Bash_Scripting.git
- Grant execution permissions:
chmod +x *.sh - Run a specific script within the same directory:
./analyze_memory.sh
- Core Fundamentals: Mastered the use of
for/whileloops, arithmetic operations using$((...)), and complexif/elif/elseconditional logic. - Positional Parameters: Understood how to use
$1,$@, and theshiftoperator to create flexible CLI tools that handle multiple arguments. - Stream Redirection: Learned about file descriptors (
1for stdout,2for 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
awkandsedfor text transformation,grepfor searching, andfindfor file management. - System Metrics: Used native tools like
free,df, andpsto 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.