Mastering Linux Shell Scripting

Master the complexities of Bash shell scripting and unlock the power of shell for your enterprise

Mastering Linux Shell Scripting

Mastering
Andrew Mallett

7 customer reviews
Master the complexities of Bash shell scripting and unlock the power of shell for your enterprise
$27.99
$34.99
RRP $27.99
RRP $34.99
eBook
Print + eBook

Instantly access this course right now and get the skills you need in 2017

With unlimited access to a constantly growing library of over 4,000 eBooks and Videos, a subscription to Mapt gives you everything you need to learn new skills. Cancel anytime.

Preview in Mapt

Book Details

ISBN 139781784396978
Paperback198 pages

Book Description

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

In this book, you’ll discover everything you need to know to master shell scripting and make informed choices about the elements you employ. Get to grips with the fundamentals of creating and running a script in normal mode, and in debug mode. Learn about various conditional statements' code snippets, and realize the power of repetition and loops in your shell script. Implement functions and edit files using the Stream Editor, script in Perl, program in Python – as well as complete coverage of other scripting languages to ensure you can choose the best tool for your project.

Table of Contents

Chapter 1: What and Why of Scripting with Bash
Bash vulnerabilities
The bash command hierarchy
Preparing text editors for scripting
Creating and executing scripts
Debugging your scripts
Summary
Chapter 2: Creating Interactive Scripts
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 entered text
Enhancing learning with simple scripts
Summary
Chapter 3: Conditions Attached
Simple decision paths using command-line lists
Verifying user input with lists
Using the test shell builtin
Creating conditional statements using if
Extending if with else
More conditions with elif
Using case statements
Script – building a front-end with grep
Summary
Chapter 4: Creating Code Snippets
Abbreviations
Using code snippets
Summary
Chapter 5: Alternative Syntax
Recapping test
Providing parameter defaults
When in doubt – Quote!
Advanced test using [[
Arithmetic operations using ((
Summary
Chapter 6: Iterating with Loops
For loops
Controlling the loop
Reading input from files
Creating operator menus
Summary
Chapter 7: Creating Building Blocks with Functions
Introducing functions
Passing parameters to functions
Returning values from functions
Using functions in menus
Summary
Chapter 8: Introducing sed
Using grep to display text
Using regular expressions
Understanding the basics of sed
Summary
Chapter 9: Automating Apache Virtual Hosts
Apache name-based Virtual Hosts
Automating Virtual Host creation
Summary
Chapter 10: Awk Fundamentals
The history behind awk
Displaying and filtering content from files
Formatting output
Further filtering to display users by UID
Awk control files
Summary
Chapter 11: Summarizing Logs with Awk
The HTTPD log file format
Displaying data from web logs
Displaying the highest ranking IP address
Displaying the browser data
Working with e-mail logs
Summary
Chapter 12: A Better lastlog with Awk
Using awk ranges to exclude data
Conditions based on the number of fields
Manipulating the awk record separator to report on XML data
Summary
Chapter 13: Using Perl as a Bash Scripting Alternative
What is Perl?
Hello World
Perl arrays
Conditional statements in Perl
Using functions within Perl
Summary
Chapter 14: Using Python as a Bash Scripting Alternative
What is Python?
Saying Hello World the Python way
Pythonic arguments
Significant whitespace
Reading user input
Summary

What You Will Learn

  • Use the type command to identify the order of command evaluation
  • Create interactive scripts that prompt for user input
  • Foster menu structures for operators with little command-line experience
  • Develop scripts that dynamically edit web configuration files to produce a new virtual host
  • Write scripts that use AWK to search and reports on log files
  • Draft effective scripts using functions as building blocks, reducing maintenance and build time
  • Make informed choices by comparing different script languages such as Perl and Python with BASH

Authors

Table of Contents

Chapter 1: What and Why of Scripting with Bash
Bash vulnerabilities
The bash command hierarchy
Preparing text editors for scripting
Creating and executing scripts
Debugging your scripts
Summary
Chapter 2: Creating Interactive Scripts
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 entered text
Enhancing learning with simple scripts
Summary
Chapter 3: Conditions Attached
Simple decision paths using command-line lists
Verifying user input with lists
Using the test shell builtin
Creating conditional statements using if
Extending if with else
More conditions with elif
Using case statements
Script – building a front-end with grep
Summary
Chapter 4: Creating Code Snippets
Abbreviations
Using code snippets
Summary
Chapter 5: Alternative Syntax
Recapping test
Providing parameter defaults
When in doubt – Quote!
Advanced test using [[
Arithmetic operations using ((
Summary
Chapter 6: Iterating with Loops
For loops
Controlling the loop
Reading input from files
Creating operator menus
Summary
Chapter 7: Creating Building Blocks with Functions
Introducing functions
Passing parameters to functions
Returning values from functions
Using functions in menus
Summary
Chapter 8: Introducing sed
Using grep to display text
Using regular expressions
Understanding the basics of sed
Summary
Chapter 9: Automating Apache Virtual Hosts
Apache name-based Virtual Hosts
Automating Virtual Host creation
Summary
Chapter 10: Awk Fundamentals
The history behind awk
Displaying and filtering content from files
Formatting output
Further filtering to display users by UID
Awk control files
Summary
Chapter 11: Summarizing Logs with Awk
The HTTPD log file format
Displaying data from web logs
Displaying the highest ranking IP address
Displaying the browser data
Working with e-mail logs
Summary
Chapter 12: A Better lastlog with Awk
Using awk ranges to exclude data
Conditions based on the number of fields
Manipulating the awk record separator to report on XML data
Summary
Chapter 13: Using Perl as a Bash Scripting Alternative
What is Perl?
Hello World
Perl arrays
Conditional statements in Perl
Using functions within Perl
Summary
Chapter 14: Using Python as a Bash Scripting Alternative
What is Python?
Saying Hello World the Python way
Pythonic arguments
Significant whitespace
Reading user input
Summary

Book Details

ISBN 139781784396978
Paperback198 pages
Read More
From 7 reviews

Read More Reviews