- Mastering Linux Shell Scripting
- Andrew Mallett
- 139字
- 2021-07-30 09:40:47
Chapter 3. Conditions Attached
I suppose we can say that we are now into the fine print of the script. These are the details that are written into our scripts using conditions to test if a statement should run or not. We are now ready to add some intelligence in scripts so our scripts become more robust, easier to use, and more reliable. Conditional statements can be written with simple command-line lists of AND
or OR
commands together or, more often, within traditional if
statements.
In this chapter we will cover the following topics:
- Simple decision paths using command-line lists
- Verifying user input with lists
- Using the test shell built-in
- Creating conditional statements using
if
- Extending
if
withelse
- More conditions with
elif
- Creating the
backup.sh
script usingelif
- Using case statements
- Script – front-end with
grep
推薦閱讀
- Facebook Application Development with Graph API Cookbook
- Node.js 10實戰
- Building Modern Web Applications Using Angular
- Learning Chef
- 零基礎玩轉區塊鏈
- Learning RabbitMQ
- Machine Learning with R Cookbook(Second Edition)
- 基于Java技術的Web應用開發
- C#程序設計(慕課版)
- Interactive Applications Using Matplotlib
- WordPress 4.0 Site Blueprints(Second Edition)
- Java面向對象程序設計
- 蘋果的產品設計之道:創建優秀產品、服務和用戶體驗的七個原則
- 動手學數據結構與算法
- 大學計算機應用基礎(Windows 7+Office 2010)(IC3)