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
41
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
87
Introduction to Git for Data Science
alexsu
0
280
Other Decks in Technology
See All in Technology
Webhook best practices for rock solid and resilient deployments
glaforge
1
290
AIエージェントを開発しよう!-AgentCore活用の勘所-
yukiogawa
0
170
20260204_Midosuji_Tech
takuyay0ne
1
160
SRE Enabling戦記 - 急成長する組織にSREを浸透させる戦いの歴史
markie1009
0
110
仕様書駆動AI開発の実践: Issue→Skill→PRテンプレで 再現性を作る
knishioka
2
660
Context Engineeringの取り組み
nutslove
0
350
Codex 5.3 と Opus 4.6 にコーポレートサイトを作らせてみた / Codex 5.3 vs Opus 4.6
ama_ch
0
150
Azure Durable Functions で作った NL2SQL Agent の精度向上に取り組んだ話/jat08
thara0402
0
190
Digitization部 紹介資料
sansan33
PRO
1
6.8k
AIと新時代を切り拓く。これからのSREとメルカリIBISの挑戦
0gm
0
1.1k
セキュリティについて学ぶ会 / 2026 01 25 Takamatsu WordPress Meetup
rocketmartue
1
300
会社紹介資料 / Sansan Company Profile
sansan33
PRO
15
400k
Featured
See All Featured
Primal Persuasion: How to Engage the Brain for Learning That Lasts
tmiket
0
250
Faster Mobile Websites
deanohume
310
31k
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
133
19k
Rails Girls Zürich Keynote
gr2m
96
14k
Practical Orchestrator
shlominoach
191
11k
Believing is Seeing
oripsolob
1
55
[SF Ruby Conf 2025] Rails X
palkan
1
750
Mozcon NYC 2025: Stop Losing SEO Traffic
samtorres
0
140
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
35
3.4k
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
31
9.9k
職位にかかわらず全員がリーダーシップを発揮するチーム作り / Building a team where everyone can demonstrate leadership regardless of position
madoxten
57
50k
State of Search Keynote: SEO is Dead Long Live SEO
ryanjones
0
120
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