|
| 1 | +<div align="center"> |
| 2 | + |
| 3 | +``` |
| 4 | +βββββββ ββββββ βββββββββββ βββ ββββββββ ββββββββββββββ ββββββββββ ββββββββββββββββ βββ βββββββ |
| 5 | +βββββββββββββββββββββββββββ βββ ββββββββββββββββββββββββββββββββββββββββββββββββββββ βββββββββββ |
| 6 | +ββββββββββββββββββββββββββββββββ βββββββββββ βββββββββββββββββββ βββ βββββββββ ββββββ ββββ |
| 7 | +ββββββββββββββββββββββββββββββββ βββββββββββ ββββββββββββββββββ βββ ββββββββββββββββ βββ |
| 8 | +βββββββββββ ββββββββββββββ βββ βββββββββββββββββββ βββββββββ βββ ββββββ βββββββββββββββ |
| 9 | +βββββββ βββ ββββββββββββββ βββ ββββββββ ββββββββββ βββββββββ βββ ββββββ βββββ βββββββ |
| 10 | +``` |
| 11 | + |
| 12 | +### *automate everything. break nothing.* |
| 13 | + |
| 14 | +<br/> |
| 15 | + |
| 16 | + |
| 17 | + |
| 18 | + |
| 19 | + |
| 20 | + |
| 21 | + |
| 22 | +<br/> |
| 23 | + |
| 24 | +> π A curated collection of **Linux Bash scripts** β from beginner fundamentals to real-world automation tools. |
| 25 | +> Built for learners, sysadmins, and developers who love the terminal. |
| 26 | +
|
| 27 | +</div> |
| 28 | + |
| 29 | +--- |
| 30 | + |
| 31 | +## π Table of Contents |
| 32 | + |
| 33 | +- [β¨ About](#-about) |
| 34 | +- [ποΈ Repository Structure](#οΈ-repository-structure) |
| 35 | +- [π Getting Started](#-getting-started) |
| 36 | +- [π Script Categories](#-script-categories) |
| 37 | +- [π οΈ Usage](#οΈ-usage) |
| 38 | +- [π‘ Tips & Best Practices](#-tips--best-practices) |
| 39 | +- [π€ Contributing](#-contributing) |
| 40 | +- [π License](#-license) |
| 41 | + |
| 42 | +--- |
| 43 | + |
| 44 | +## β¨ About |
| 45 | + |
| 46 | +This repository is a **hands-on learning ground** for Linux Bash Scripting. |
| 47 | + |
| 48 | +Whether you're just starting out with shell scripts or looking to sharpen your automation game, you'll find practical, well-commented scripts covering a wide range of topics β from basic syntax and control flow to file manipulation, process management, and beyond. |
| 49 | + |
| 50 | +```bash |
| 51 | +$ echo "Why learn Bash?" |
| 52 | +> Because the terminal is where the real power lives. |
| 53 | +``` |
| 54 | + |
| 55 | +--- |
| 56 | + |
| 57 | +## ποΈ Repository Structure |
| 58 | + |
| 59 | +``` |
| 60 | +Linux-Bash-Scripting/ |
| 61 | +β |
| 62 | +βββ π basics/ # Variables, input/output, comments |
| 63 | +βββ π control-flow/ # if/else, loops, case statements |
| 64 | +βββ π functions/ # Reusable functions and libraries |
| 65 | +βββ π file-operations/ # Read, write, parse, manipulate files |
| 66 | +βββ π system-admin/ # Disk, memory, process monitoring |
| 67 | +βββ π networking/ # Ping checks, port scanners, curl scripts |
| 68 | +βββ π automation/ # Cron jobs, backups, schedulers |
| 69 | +βββ π text-processing/ # awk, sed, grep, cut, sort |
| 70 | +βββ π projects/ # End-to-end real-world mini-projects |
| 71 | +``` |
| 72 | + |
| 73 | +--- |
| 74 | + |
| 75 | +## π Getting Started |
| 76 | + |
| 77 | +### Prerequisites |
| 78 | + |
| 79 | +Make sure you have the following: |
| 80 | + |
| 81 | +- A **Linux / macOS** system (or WSL on Windows) |
| 82 | +- `bash` version **4.0+** |
| 83 | + |
| 84 | +```bash |
| 85 | +bash --version |
| 86 | +``` |
| 87 | + |
| 88 | +### Clone the Repository |
| 89 | + |
| 90 | +```bash |
| 91 | +git clone https://github.com/Kishan-Miskin/Linux-Bash-Scripting.git |
| 92 | +cd Linux-Bash-Scripting |
| 93 | +``` |
| 94 | + |
| 95 | +### Run Your First Script |
| 96 | + |
| 97 | +```bash |
| 98 | +chmod +x basics/hello_world.sh |
| 99 | +./basics/hello_world.sh |
| 100 | +``` |
| 101 | + |
| 102 | +--- |
| 103 | + |
| 104 | +## π Script Categories |
| 105 | + |
| 106 | +<table> |
| 107 | + <thead> |
| 108 | + <tr> |
| 109 | + <th>Category</th> |
| 110 | + <th>Description</th> |
| 111 | + <th>Difficulty</th> |
| 112 | + </tr> |
| 113 | + </thead> |
| 114 | + <tbody> |
| 115 | + <tr> |
| 116 | + <td>π’ <strong>Basics</strong></td> |
| 117 | + <td>Variables, data types, user input, echo/printf</td> |
| 118 | + <td>Beginner</td> |
| 119 | + </tr> |
| 120 | + <tr> |
| 121 | + <td>π’ <strong>Control Flow</strong></td> |
| 122 | + <td>if/elif/else, for, while, until, case</td> |
| 123 | + <td>Beginner</td> |
| 124 | + </tr> |
| 125 | + <tr> |
| 126 | + <td>π‘ <strong>Functions</strong></td> |
| 127 | + <td>Declaring, calling, scoping, return values</td> |
| 128 | + <td>Intermediate</td> |
| 129 | + </tr> |
| 130 | + <tr> |
| 131 | + <td>π‘ <strong>File Operations</strong></td> |
| 132 | + <td>Reading files, writing logs, parsing CSVs</td> |
| 133 | + <td>Intermediate</td> |
| 134 | + </tr> |
| 135 | + <tr> |
| 136 | + <td>π‘ <strong>Text Processing</strong></td> |
| 137 | + <td>awk, sed, grep, tr, cut, sort, uniq</td> |
| 138 | + <td>Intermediate</td> |
| 139 | + </tr> |
| 140 | + <tr> |
| 141 | + <td>π΄ <strong>System Admin</strong></td> |
| 142 | + <td>CPU/RAM monitoring, disk usage, process management</td> |
| 143 | + <td>Advanced</td> |
| 144 | + </tr> |
| 145 | + <tr> |
| 146 | + <td>π΄ <strong>Networking</strong></td> |
| 147 | + <td>Ping sweeps, port scanning, curl API calls</td> |
| 148 | + <td>Advanced</td> |
| 149 | + </tr> |
| 150 | + <tr> |
| 151 | + <td>π΄ <strong>Automation</strong></td> |
| 152 | + <td>Backup scripts, cron jobs, scheduled tasks</td> |
| 153 | + <td>Advanced</td> |
| 154 | + </tr> |
| 155 | + </tbody> |
| 156 | +</table> |
| 157 | + |
| 158 | +--- |
| 159 | + |
| 160 | +## π οΈ Usage |
| 161 | + |
| 162 | +### Making a Script Executable |
| 163 | + |
| 164 | +```bash |
| 165 | +chmod +x script_name.sh |
| 166 | +./script_name.sh |
| 167 | +``` |
| 168 | + |
| 169 | +### Running with Bash Directly |
| 170 | + |
| 171 | +```bash |
| 172 | +bash script_name.sh |
| 173 | +``` |
| 174 | + |
| 175 | +### Passing Arguments |
| 176 | + |
| 177 | +```bash |
| 178 | +./script.sh arg1 arg2 |
| 179 | +# Inside script: $1 = arg1, $2 = arg2 |
| 180 | +``` |
| 181 | + |
| 182 | +### Debugging a Script |
| 183 | + |
| 184 | +```bash |
| 185 | +bash -x script.sh # Trace execution |
| 186 | +bash -n script.sh # Syntax check only |
| 187 | +``` |
| 188 | + |
| 189 | +--- |
| 190 | + |
| 191 | +## π‘ Tips & Best Practices |
| 192 | + |
| 193 | +```bash |
| 194 | +# β
Always start with a shebang |
| 195 | +#!/bin/bash |
| 196 | + |
| 197 | +# β
Use quotes around variables |
| 198 | +echo "$variable" # Prevents word splitting |
| 199 | + |
| 200 | +# β
Check command success |
| 201 | +if ! mkdir /tmp/mydir; then |
| 202 | + echo "Failed to create directory" |
| 203 | +fi |
| 204 | + |
| 205 | +# β
Use meaningful variable names |
| 206 | +user_home="$HOME" |
| 207 | + |
| 208 | +# β
Trap errors for cleanup |
| 209 | +trap 'echo "Error on line $LINENO"' ERR |
| 210 | +``` |
| 211 | + |
| 212 | +| β
Do This | β Avoid This | |
| 213 | +|---|---| |
| 214 | +| Quote your variables `"$var"` | Unquoted variables `$var` | |
| 215 | +| Use `[[` for conditionals | Use `[` without escaping | |
| 216 | +| Add `set -e` for strict mode | Silent failure on errors | |
| 217 | +| Comment your logic | Writing cryptic one-liners | |
| 218 | +| Use `local` for function vars | Global vars everywhere | |
| 219 | + |
| 220 | +--- |
| 221 | + |
| 222 | +## π€ Contributing |
| 223 | + |
| 224 | +Contributions are warmly welcome! π |
| 225 | + |
| 226 | +```bash |
| 227 | +# 1. Fork the repository |
| 228 | +# 2. Create your feature branch |
| 229 | +git checkout -b feature/my-awesome-script |
| 230 | + |
| 231 | +# 3. Commit your changes |
| 232 | +git commit -m "Add: system health check script" |
| 233 | + |
| 234 | +# 4. Push to your branch |
| 235 | +git push origin feature/my-awesome-script |
| 236 | + |
| 237 | +# 5. Open a Pull Request |
| 238 | +``` |
| 239 | + |
| 240 | +### Guidelines |
| 241 | + |
| 242 | +- π Add comments to explain what your script does |
| 243 | +- π§ͺ Test your script before submitting |
| 244 | +- π Place scripts in the correct category folder |
| 245 | +- π€ Use `snake_case` for file names (e.g., `disk_usage.sh`) |
| 246 | + |
| 247 | +--- |
| 248 | + |
| 249 | +## π License |
| 250 | + |
| 251 | +This project is licensed under the **MIT License** β feel free to use, share, and modify. |
| 252 | + |
| 253 | +--- |
| 254 | + |
| 255 | +<div align="center"> |
| 256 | + |
| 257 | +**Made with π€ and a lot of `$ _`** |
| 258 | + |
| 259 | +[](https://github.com/Kishan-Miskin) |
| 260 | + |
| 261 | +*If this repo helped you, drop a β β it means the world!* |
| 262 | + |
| 263 | +</div> |
0 commit comments