Cargando…

Mastering Linux Shell Scripting : a practical guide to Linux command-line, Bash scripting, and Shell programming, 2nd Edition.

Shell scripting is a quick method to prototype a complex application or a problem by automating tasks when working on Linux-based systems. This book will make use of both simple one-line commands and command sequences and complex problems can be solved with ease, from text processing to backing up s...

Descripción completa

Detalles Bibliográficos
Clasificación:Libro Electrónico
Autor principal: Ebrahim, Mokhtar
Otros Autores: Mallett, Andrew
Formato: Electrónico eBook
Idioma:Inglés
Publicado: Birmingham : Packt Publishing, 2018.
Edición:2nd ed.
Temas:
Acceso en línea:Texto completo
Tabla de Contenidos:
  • Cover; Copyright and Credits; Packt Upsell; Contributors; Table of Contents; Preface; Chapter 1: The What and Why of Scripting with Bash; Technical requirements; Types of Linux shells; What is bash scripting?; The bash command hierarchy; Command type; Command PATH; Preparing text editors for scripting; Configuring vim; Configuring nano; Configuring gedit; Creating and executing scripts; Hello World!; Executing the script; Checking the exit status; Ensuring a unique name; Hello Dolly!; Running the script with arguments; The importance of correct quotes; Printing the script name.
  • Declaring variablesUser-defined variables; Environment variables; Variable scope; Command substitution; Debugging your scripts; Summary; Questions; Further reading; Chapter 2: Creating Interactive Scripts; Technical requirements; Using echo with options; Basic script using read; Script comments; Enhancing scripts with read prompts; Limiting the number of entered characters; Controlling the visibility of the entered text; Passing options; Passing parameters with options; Read options values; Try to be standard; Enhancing learning with simple scripts; Backing-up with scripts.
  • Connecting to a serverVersion 1
  • ping; Version 2
  • SSH; Version 3
  • MySQL/MariaDB; Reading files; Summary; Questions; Further reading; Chapter 3: Conditions Attached; Technical requirements; Simple decision paths using command-line lists; Verifying user input with lists; Using the test shell built-in; Testing strings; Testing integers; Testing file types; Creating conditional statements using if; Extending if with else; Test command with the if command; Checking strings; Checking files and directories; Checking numbers; Combining tests; More conditions with elif.
  • Creating the backup2.sh using elifUsing case statements; Recipe
  • building a frontend with grep; Summary; Questions; Further reading; Chapter 4: Creating Code Snippets; Technical requirements; Abbreviations; Using code snippets; Bringing color to the Terminal; Creating snippets using VS Code; Summary; Questions; Further reading; Chapter 5: Alternative Syntax; Technical requirement; Recapping the test command; Testing files; Adding logic; Square brackets as not seen before; Providing parameter defaults; Variables; Special parameters; Setting defaults; When in doubt
  • quote!
  • Advanced tests using [[White space; Other advanced features; Pattern matching; Regular expressions; Regular expression script; Arithmetic operations using ((; Simple math; Parameter manipulation; Standard arithmetic tests; Summary; Questions; Further reading; Chapter 6: Iterating with Loops; Technical requirement; for loops; Advanced for loops; The IFS; Counting directories and files; C-style for loops ; Nested loops; Redirecting loop output; Controlling the loop; while loops and until loops; Reading input from files; Creating operator menus; Summary; Questions; Further reading.