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

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
主站蜘蛛池模板: 柯坪县| 九江县| 临桂县| 沙雅县| 治县。| 金坛市| 固阳县| 安西县| 新津县| 于都县| 达拉特旗| 岐山县| 娄底市| 海伦市| 东兰县| 北辰区| 许昌县| 宜兰市| 黎川县| 金塔县| 恩施市| 达孜县| 买车| 土默特左旗| 历史| 高碑店市| 六安市| 海口市| 夏河县| 行唐县| 孝感市| 秭归县| 西平县| 长沙县| 杭州市| 桦川县| 平遥县| 石河子市| 崇信县| 贵德县| 松滋市|