官术网_书友最值得收藏!

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 with else
  • More conditions with elif
  • Creating the backup.sh script using elif
  • Using case statements
  • Script – front-end with grep
主站蜘蛛池模板: 鹿泉市| 新野县| 山西省| 平乐县| 大冶市| 虞城县| 忻州市| 织金县| 青川县| 长乐市| 喀喇沁旗| 略阳县| 新兴县| 苍南县| 永和县| 江口县| 阳春市| 克什克腾旗| 五原县| 樟树市| 西宁市| 姜堰市| 陵水| 塔河县| 自贡市| 泽州县| 佛学| 肇源县| 景德镇市| 昔阳县| 芜湖市| 阆中市| 美姑县| 聂拉木县| 阳泉市| 鲜城| 锡林浩特市| 洛隆县| 南华县| 收藏| 镇原县|