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
CDK対応したAWS DevOps Agentを試そう_20260201
masakiokuda
1
290
Bill One 開発エンジニア 紹介資料
sansan33
PRO
4
17k
Contract One Engineering Unit 紹介資料
sansan33
PRO
0
13k
ブロックテーマでサイトをリニューアルした話 / 2026-01-31 Kansai WordPress Meetup
torounit
0
470
インフラエンジニア必見!Kubernetesを用いたクラウドネイティブ設計ポイント大全
daitak
1
360
Codex 5.3 と Opus 4.6 にコーポレートサイトを作らせてみた / Codex 5.3 vs Opus 4.6
ama_ch
0
150
All About Sansan – for New Global Engineers
sansan33
PRO
1
1.3k
外部キー制約の知っておいて欲しいこと - RDBMSを正しく使うために必要なこと / FOREIGN KEY Night
soudai
PRO
12
5.5k
Bedrock PolicyでAmazon Bedrock Guardrails利用を強制してみた
yuu551
0
230
CDKで始めるTypeScript開発のススメ
tsukuboshi
1
420
Data Hubグループ 紹介資料
sansan33
PRO
0
2.7k
Introduction to Bill One Development Engineer
sansan33
PRO
0
360
Featured
See All Featured
Abbi's Birthday
coloredviolet
1
4.7k
Leveraging LLMs for student feedback in introductory data science courses - posit::conf(2025)
minecr
0
140
Prompt Engineering for Job Search
mfonobong
0
160
A Soul's Torment
seathinner
5
2.3k
Building Better People: How to give real-time feedback that sticks.
wjessup
370
20k
30 Presentation Tips
portentint
PRO
1
220
Darren the Foodie - Storyboard
khoart
PRO
2
2.4k
Connecting the Dots Between Site Speed, User Experience & Your Business [WebExpo 2025]
tammyeverts
11
830
Data-driven link building: lessons from a $708K investment (BrightonSEO talk)
szymonslowik
1
910
Evolving SEO for Evolving Search Engines
ryanjones
0
120
ReactJS: Keep Simple. Everything can be a component!
pedronauck
666
130k
Automating Front-end Workflow
addyosmani
1371
200k
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