⌨️ Bash Basic Lessons
Terminal ထဲမှာ file/folder စီမံတာ၊ command တွေ run တာ၊ text search/process လုပ်တာနဲ့ automation script ရေးတာကို အခြေခံကနေ သင်မယ်။
Bash Intro
Bash က Linux/macOS terminal shell တစ်ခုဖြစ်ပြီး Windows မှာ Git Bash, WSL, PowerShell terminal ကနေသုံးနိုင်ပါတယ်။ Developer workflow မှာ Git, Node, Docker, server deploy တွေနဲ့အမြဲတွေ့ရတယ်။
whoami
date
echo "Hello Bash"
Bash Commands
Command တစ်ခုမှာ command name, options, arguments ဆိုပြီးရှိတတ်ပါတယ်။
command --option argument
ls -la /home/user
mkdir projects
Files: cat, cp, mv, rm
cat notes.txt
cp notes.txt backup.txt
mv backup.txt old-notes.txt
rm old-notes.txt
rm က delete လုပ်တာဖြစ်လို့ သေချာစစ်ပြီးမှ run ပါ။
touch, mkdir, man
touch app.log
mkdir src
mkdir -p app/controllers
man ls
Bash Alias
Alias က command အရှည်ကို short name ပေးတာပါ။
alias ll="ls -la"
alias gs="git status"
# ~/.bashrc ထဲထည့်ပြီး terminal restart လုပ်ပါ
Text Processing: grep, awk, sed
grep "error" app.log
awk '{ print $1 }' access.log
sed 's/old/new/g' file.txt
grepက search လုပ်တယ်awkက columns/data process လုပ်တယ်sedက stream edit/replace လုပ်တယ်
Permissions
chmod +x deploy.sh
chmod 644 config.txt
chown user:user file.txt
Bash Scripts
Command တွေကို file ထဲစုရေးပြီး automation လုပ်နိုင်ပါတယ်။
#!/usr/bin/env bash
echo "Deploy start"
git pull
docker compose up -d
echo "Done"