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

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
主站蜘蛛池模板: 普安县| 东乌珠穆沁旗| 富宁县| 堆龙德庆县| 花垣县| 平舆县| 黔西| 崇仁县| 双流县| 资源县| 盐源县| 绥德县| 重庆市| 霍邱县| 瑞金市| 绥宁县| 柘城县| 岳池县| 五家渠市| 渑池县| 右玉县| 西乌珠穆沁旗| 石狮市| 大余县| 临颍县| 洛川县| 潼关县| 山阴县| 滦平县| 新晃| 高陵县| 永寿县| 贵溪市| 宜都市| 千阳县| 白沙| 南乐县| 从化市| 建阳市| 察雅县| 启东市|