< Previous | Contents | Next >
Part 4 – Writing Shell Scripts
24 – Writing Your First ScriptWhat Are Shell Scripts?How To Write A Shell ScriptScript File FormatExecutable PermissionsScript File LocationGood Locations For ScriptsMore Formatting TricksLong Option NamesIndentation And line-continuationSumming UpFurther Reading25 – Starting A ProjectFirst Stage: Minimal DocumentSecond Stage: Adding A Little DataVariables And ConstantsAssigning Values To Variables And ConstantsHere DocumentsSumming UpFurther Reading26 – Top-Down DesignShell FunctionsLocal VariablesKeep Scripts RunningSumming UpFurther Reading27 – Flow Control: Branching With ififExit StatustestFile ExpressionsString ExpressionsInteger ExpressionsA More Modern Version Of test(( )) - Designed For IntegersCombining ExpressionsControl Operators: Another Way To BranchSumming UpFurther Reading28 – Reading Keyboard Inputread – Read Values From Standard InputOptionsIFSValidating InputMenusSumming UpExtra CreditFurther Reading29 – Flow Control: Looping With while / untilLoopingwhileBreaking Out Of A LoopuntilReading Files With LoopsSumming UpFurther Reading30 – TroubleshootingSyntactic ErrorsMissing QuotesMissing Or Unexpected TokensUnanticipated ExpansionsLogical ErrorsDefensive ProgrammingVerifying InputTestingTest CasesDebuggingFinding The Problem AreaTracingExamining Values During ExecutionSumming UpFurther Reading31 – Flow Control: Branching With casecasePatternsPerforming Multiple ActionsSumming UpFurther Reading32 – Positional ParametersAccessing The Command LineDetermining The Number of Argumentsshift – Getting Access To Many ArgumentsSimple ApplicationsUsing Positional Parameters With Shell FunctionsHandling Positional Parameters En MasseA More Complete ApplicationSumming UpFurther Reading33 – Flow Control: Looping With forfor: Traditional Shell Formfor: C Language FormSumming UpFurther Reading34 – Strings And NumbersParameter ExpansionBasic ParametersExpansions To Manage Empty VariablesExpansions That Return Variable NamesString OperationsCase ConversionArithmetic Evaluation And ExpansionNumber BasesUnary OperatorsSimple ArithmeticAssignmentBit OperationsLogicbc – An Arbitrary Precision Calculator LanguageUsing bcAn Example ScriptSumming UpExtra CreditFurther Reading35 – ArraysWhat Are Arrays?Creating An ArrayAssigning Values To An ArrayAccessing Array ElementsArray OperationsOutputting The Entire Contents Of An ArrayDetermining The Number Of Array ElementsFinding The Subscripts Used By An ArrayAdding Elements To The End Of An ArraySorting An ArrayDeleting An ArrayAssociative ArraysSumming UpFurther Reading36 – ExoticaGroup Commands And SubshellsProcess SubstitutionTrapsAsynchronous ExecutionwaitNamed PipesSetting Up A Named PipeUsing Named PipesSumming UpFurther ReadingIndex