FILE: materi-18.module

Bash Scripting

Otomasi task repetitive. Variables, conditionals, loops, functions di shell.

RUNTIME: 24m LEVEL: beginner STATUS: ACTIVE
> BASH SCRIPTING $ Automate everything [OK] Module loaded successfully [INFO] Ready for next stage

1. Apa Itu Bash

Bourne Again Shell. Shell default Linux. Lebih dari sekedar CLI: bahasa scripting full-featured. Setiap DevOps wajib bisa baca dan tulis bash. Job interview pasti tanya.

2. Variables dan Quoting

VAR=value tanpa space. Double quote: expansion. Single quote: literal. Backtick atau dollar paren untuk command substitution. Hati-hati: bash quoting menyebalkan.

3. Conditionals

if [ condition ]; then... fi. Operator: -eq, -ne, -lt, -gt, -f (file ada), -d (directory). && dan || untuk chain. Case statement untuk multiple branch.

4. Loops

for var in list; do... done. while [ condition ]; do... done. break dan continue. Loop file: for f in *.txt. Loop angka: for i in {1..10}.

5. Practical Example

Backup script harian. Log rotator. System health check. Deploy script. Monitoring custom. Pipe output ke sed, awk untuk text manipulation. Cronjob untuk schedule.

Practical Mission

  1. Tulis backup script otomatis
  2. Buat health check script (disk, memory, CPU)
  3. Otomasi setup laptop baru
  4. Pelajari shellcheck untuk lint script
  5. Schedule script dengan cron

Recap Module