Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Shell scripting 基本教學
Search
Alex
March 04, 2019
Technology
0
40
Shell scripting 基本教學
Alex
March 04, 2019
Tweet
Share
More Decks by Alex
See All by Alex
How to integrate GitLab CICD into B2B service.pdf
alexsu
0
290
Jenkins Quick Guide
alexsu
0
130
Vim 基本操作
alexsu
1
110
Top IDEs & Code Editors for Data Science
alexsu
0
44
Linux_Command-line_指令與基本操作.pdf
alexsu
0
86
Introduction to Git for Data Science
alexsu
0
280
Other Decks in Technology
See All in Technology
2026年、サーバーレスの現在地 -「制約と戦う技術」から「当たり前の実行基盤」へ- /serverless2026
slsops
2
240
Ruby版 JSXのRuxが気になる
sansantech
PRO
0
150
Amazon S3 Vectorsを使って資格勉強用AIエージェントを構築してみた
usanchuu
3
450
制約が導く迷わない設計 〜 信頼性と運用性を両立するマイナンバー管理システムの実践 〜
bwkw
3
930
AIエージェントを開発しよう!-AgentCore活用の勘所-
yukiogawa
0
170
登壇駆動学習のすすめ — CfPのネタの見つけ方と書くときに意識していること
bicstone
3
100
生成AI時代にこそ求められるSRE / SRE for Gen AI era
ymotongpoo
5
3.2k
GitHub Issue Templates + Coding Agentで簡単みんなでIaC/Easy IaC for Everyone with GitHub Issue Templates + Coding Agent
aeonpeople
1
230
What happened to RubyGems and what can we learn?
mikemcquaid
0
300
Bill One 開発エンジニア 紹介資料
sansan33
PRO
4
17k
FinTech SREのAWSサービス活用/Leveraging AWS Services in FinTech SRE
maaaato
0
130
Amazon Bedrock Knowledge Basesチャンキング解説!
aoinoguchi
0
140
Featured
See All Featured
Crafting Experiences
bethany
1
49
Building Flexible Design Systems
yeseniaperezcruz
330
40k
SEO in 2025: How to Prepare for the Future of Search
ipullrank
3
3.3k
Between Models and Reality
mayunak
1
190
Money Talks: Using Revenue to Get Sh*t Done
nikkihalliwell
0
150
Designing for Timeless Needs
cassininazir
0
130
Taking LLMs out of the black box: A practical guide to human-in-the-loop distillation
inesmontani
PRO
3
2k
Fireside Chat
paigeccino
41
3.8k
[SF Ruby Conf 2025] Rails X
palkan
1
750
Producing Creativity
orderedlist
PRO
348
40k
How to Grow Your eCommerce with AI & Automation
katarinadahlin
PRO
1
110
Google's AI Overviews - The New Search
badams
0
910
Transcript
Shell scripting 基本教學 蘇民弦 (Alex)
為什麼要學 Shell Scripting 1. 程式自動化 2. 利用程式邏輯管理電腦和工作程序 3. 減少單一重複的動作
步驟 1. 建立一個 shell script (.sh) 2. 撰寫 Shell Scripting
程式 3. 執行程式 `$ sh scripting.sh` 4. 或搭配 crontab 自動化
#!bin/bash # 聲明用哪個 Shell echo “Hello World” # 印出 “Hello
World” 字串 mkdir MyFolder # 建立一個資料夾 touch ./MyFolder/file.r # 在這個資料夾新增一個 file.r 檔案 撰寫第一個 Shell Scripting 腳本
預設環境變數 echo $SHELL # 目前使用的 shell echo $PATH # 路徑
echo $USER # 使用者 echo $HOME # 家目錄路徑 echo $HOSTNAME # 主機名稱
自訂變數 a=100 b=50 c=”Hello World!” echo $a # 呼叫變數,前面一定要加一個 $
echo $c
四則運算 x=50 y=10 a=`expr $x + $y` # 加法 b=`expr
$x - $y` # 減法 c=`expr $x \* $y` # 乘法 d=`expr $x / $y` # 除法 e=`expr $x % $y` # 餘數
迴圈 (loop) 1 加到 10 的小程式
迴圈 (while) 1 加到 10 的小程式
判斷式 (if else) 比大小程式
資料庫備份小程式 Shell Scripting 範例
練習 • 寫一個監控自己電腦的程式 • 寫一個自動在 5/1 寄給自己,提醒鳳梨罐頭已經過期的信 • 搭配先前學到的處理字串的技巧,練習在 Shell
處理資料 • 寫一個自動安裝程式的 scripts