Upgrade to PRO for Only $50/Year—Limited-Time Offer! 🔥
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Shell scripting 基本教學
Search
Alex
March 04, 2019
Technology
0
37
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
41
Linux_Command-line_指令與基本操作.pdf
alexsu
0
84
Introduction to Git for Data Science
alexsu
0
280
Other Decks in Technology
See All in Technology
コミューンのデータ分析AIエージェント「Community Sage」の紹介
fufufukakaka
0
440
AI時代の開発フローとともに気を付けたいこと
kkamegawa
0
2.3k
eBPFとwaruiBPF
sat
PRO
4
2.5k
第4回 「メタデータ通り」 リアル開催
datayokocho
0
120
直接メモリアクセス
koba789
0
280
regrowth_tokyo_2025_securityagent
hiashisan
0
170
Reinforcement Fine-tuning 基礎〜実践まで
ch6noota
0
160
寫了幾年 Code,然後呢?軟體工程師必須重新認識的 DevOps
cheng_wei_chen
1
1k
エンジニアリングマネージャー はじめての目標設定と評価
halkt
0
250
AI 駆動開発勉強会 フロントエンド支部 #1 w/あずもば
1ftseabass
PRO
0
210
会社紹介資料 / Sansan Company Profile
sansan33
PRO
11
390k
Challenging Hardware Contests with Zephyr and Lessons Learned
iotengineer22
0
120
Featured
See All Featured
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
35
3.3k
Mobile First: as difficult as doing things right
swwweet
225
10k
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
194
17k
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
49
3.2k
Context Engineering - Making Every Token Count
addyosmani
9
490
Docker and Python
trallard
47
3.7k
Thoughts on Productivity
jonyablonski
73
5k
[RailsConf 2023] Rails as a piece of cake
palkan
58
6.1k
10 Git Anti Patterns You Should be Aware of
lemiorhan
PRO
659
61k
How to Think Like a Performance Engineer
csswizardry
28
2.4k
Raft: Consensus for Rubyists
vanstee
141
7.2k
The Art of Programming - Codeland 2020
erikaheidi
56
14k
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