O'Reilly logo

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Linux Shell Scripting: Automating Command Line Tasks

Video Description

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

About This Video

  • Avoid over-engineering; in most cases there is always a simple solution
  • Understand the internals; everything is based on simple concepts
  • Learn to debug and debug to learn

In Detail

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.

Downloading the example code for this course: You can download the example code files for all Packt video courses you have purchased from your account at http://www.PacktPub.com. If you purchased this course elsewhere, you can visit http://www.PacktPub.com/support and register to have the files e-mailed directly to you.

Table of Contents

  1. Chapter 1 : Shell Is an Interpreter
    1. The Course Overview 00:02:44
    2. Shell Commands- Commands Are Built-In Scripts 00:08:38
    3. Documentation- Reading the Man Pages 00:03:37
    4. The First Shell Script – Using Shell Commands in the Scripts 00:05:07
    5. Calling the Shell Scripts – Different Ways to Call the Same Script 00:02:56
  2. Chapter 2 : Calling the Script with Parameters
    1. Variables – Passing Command-Line Arguments to a Script 00:03:32
    2. The First Argument – The Path of the Script 00:01:15
    3. The Order of the Arguments – Order Matters! 00:04:34
    4. Types of Arguments – Strings, Numbers, and Special Characters 00:07:08
    5. Parsing the Arguments – getopts 00:03:17
  3. Chapter 3 : Chaining and Redirection
    1. Standard Input and Output – Input and Output Redirection and EOF 00:06:56
    2. File I/O – Reading from a File and Writing to a File 00:04:40
    3. Detaching from the Shell – Screen Utility and the & 00:04:55
    4. Rewriting and Appending – The First Log 00:04:29
    5. Environmental Variables – Playing with the PATH 00:03:14
  4. Chapter 4 : Defining and Calling Functions
    1. The Functions – Function Is an Action 00:03:24
    2. Function Variables – Passing Arguments and Returning Values 00:04:13
    3. Variable Scopes – It Is Not the Same Everywhere 00:02:41
    4. Overloading – Redefining the Shell Commands 00:01:56
    5. Naming – Naming Conventions 00:02:23
  5. Chapter 5 : Looping and Branching
    1. Loops – for and while Loops 00:04:53
    2. Branching – if/then/else and Case 00:04:06
    3. Combining Loops and Branches – Nested Loops and Branches 00:01:32
    4. Branching and Arguments – An Example init Script 00:04:25
    5. Title 00:02:15
  6. Chapter 6 : Parsing and Regular Expressions
    1. Parsing – Check Whether It Is a Number 00:03:33
    2. Regex – Introduction to Regex 00:04:49
    3. Regex Flavors – It Is Not the Same Everywhere 00:01:46
    4. Globbing – Globbing Is Not Regex 00:03:36
    5. Practice – Practicing Is the Only Way 00:02:41
  7. Chapter 7 : Learning to Learn and Log
    1. Linux Logs – All Kinds of Logs 00:03:45
    2. Logging – Use Logger to Write Your Logs 00:03:01
    3. Reading the Logs – cut, tail, head, and grep 00:04:19
    4. System Calls – What strace Shows 00:02:43
    5. The Last Call – Putting It All Together 00:05:01