Linux Shell Scripting: Automating Command Line Tasks

Linux Shell Scripting: Automating Command Line Tasks

English | MP4 | AVC 1920×1080 | AAC 48KHz 2ch | 2h 14m | 501 MB

Solve complex shell-related problems and efficiently automate your day-to-day tasks

Shell scripting involves writing a series of command for the shell to execute. It combines lengthy and repetitive sequences of commands into a single script, which can be stored and executed anytime. This reduces the effort required by the end user and the number of human mistakes.

You will write your first shell script and delve into the shell, to touch the power CLI which provides against the GUI. Also you will learn simple arguments and use getopts to make it a real Shell command. Then you will learn looping and functions for performing complex operations. You will then master Regex and regular expressions to validate your arguments. Finally, you will learn to write logs correctly and fight the temptation to use I/O redirections.

By the end of this course, you will be an expert at creating powerful shell scripts and will have explored the full possibilities of shells.

This course starts with the simplest possible concept—listing the content of a folder—and leads you to an understanding of what a Linux OS System call is. You will see how programs interact with the OS, and what happens under the hood when you run a script of your own. You will solve tasks in the wrong way first and then learn to do so correctly, with the chance to compare using I/O redirection and the logger utility to write your own logs. The author will ask the question “What will happen?” before firing a command for a concept that has just been explained; that will be your queue to hit the Pause button and think.

What You Will Learn

  • Choose the right automation technique
  • Write user-friendly scripts
  • Debug the system, not scripts
  • Write complex scripts with branches and loops
  • Delve into Linux system calls
  • Profile scripts and increase performance
  • Set up and secure a cloud MySQL database for your web app
  • Add logging to your scripts
Table of Contents

Shell Is an Interpreter
1 The Course Overview
2 Shell Commands- Commands Are Built-In Scripts
3 Documentation- Reading the Man Pages
4 The First Shell Script – Using Shell Commands in the Scripts
5 Calling the Shell Scripts – Different Ways to Call the Same Script

Calling the Script with Parameters
6 Variables – Passing Command-Line Arguments to a Script
7 The First Argument – The Path of the Script
8 The Order of the Arguments – Order Matters!
9 Types of Arguments – Strings, Numbers, and Special Characters
10 Parsing the Arguments – getopts

Chaining and Redirection
11 Standard Input and Output – Input and Output Redirection and EOF
12 File I O – Reading from a File and Writing to a File
13 Detaching from the Shell – Screen Utility and the &
14 Rewriting and Appending – The First Log
15 Environmental Variables – Playing with the PATH

Defining and Calling Functions
16 The Functions – Function Is an Action
17 Function Variables – Passing Arguments and Returning Values
18 Variable Scopes – It Is Not the Same Everywhere
19 Overloading – Redefining the Shell Commands
20 Naming – Naming Conventions

Looping and Branching
21 Loops – for and while Loops
22 Branching – if then else and Case
23 Combining Loops and Branches – Nested Loops and Branches
24 Branching and Arguments – An Example init Script
25 Title

Parsing and Regular Expressions
26 Parsing – Check Whether It Is a Number
27 Regex – Introduction to Regex
28 Regex Flavors – It Is Not the Same Everywhere
29 Globbing – Globbing Is Not Regex
30 Practice – Practicing Is the Only Way

Learning to Learn and Log
31 Linux Logs – All Kinds of Logs
32 Logging – Use Logger to Write Your Logs
33 Reading the Logs – cut, tail, head, and grep
34 System Calls – What strace Shows
35 The Last Call – Putting It All Together