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
36
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
270
Jenkins Quick Guide
alexsu
0
130
Vim 基本操作
alexsu
1
100
Top IDEs & Code Editors for Data Science
alexsu
0
40
Linux_Command-line_指令與基本操作.pdf
alexsu
0
82
Introduction to Git for Data Science
alexsu
0
280
Other Decks in Technology
See All in Technology
Model Mondays S2E02: Model Context Protocol
nitya
0
220
CI/CD/IaC 久々に0から環境を作ったらこうなりました
kaz29
1
170
Github Copilot エージェントモードで試してみた
ochtum
0
100
VISITS_AIIoTビジネス共創ラボ登壇資料.pdf
iotcomjpadmin
0
160
Yamla: Rustでつくるリアルタイム性を追求した機械学習基盤 / Yamla: A Rust-Based Machine Learning Platform Pursuing Real-Time Capabilities
lycorptech_jp
PRO
3
120
Windows 11 で AWS Documentation MCP Server 接続実践/practical-aws-documentation-mcp-server-connection-on-windows-11
emiki
0
960
Clineを含めたAIエージェントを 大規模組織に導入し、投資対効果を考える / Introducing AI agents into your organization
i35_267
4
1.6k
Кто отправит outbox? Валентин Удальцов, автор канала Пых
lamodatech
0
340
2年でここまで成長!AWSで育てたAI Slack botの軌跡
iwamot
PRO
4
700
BrainPadプログラミングコンテスト記念LT会2025_社内イベント&問題解説
brainpadpr
1
160
Welcome to the LLM Club
koic
0
170
rubygem開発で鍛える設計力
joker1007
2
200
Featured
See All Featured
Bash Introduction
62gerente
614
210k
The World Runs on Bad Software
bkeepers
PRO
69
11k
Rebuilding a faster, lazier Slack
samanthasiow
82
9.1k
The Power of CSS Pseudo Elements
geoffreycrofte
77
5.8k
Speed Design
sergeychernyshev
32
1k
A Modern Web Designer's Workflow
chriscoyier
694
190k
Why Our Code Smells
bkeepers
PRO
337
57k
Practical Orchestrator
shlominoach
188
11k
Art, The Web, and Tiny UX
lynnandtonic
299
21k
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
34
5.9k
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
507
140k
ReactJS: Keep Simple. Everything can be a component!
pedronauck
667
120k
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