Mastering Linux Shell Scripting

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

Mastering Linux Shell Scripting

Andrew Mallett

1 customer reviews
Master the complexities of Bash shell scripting and unlock the power of shell for your enterprise
Mapt Subscription
FREE
$29.99/m after trial
eBook
$19.60
RRP $27.99
Save 29%
Print + eBook
$34.99
RRP $34.99
What do I get with a Mapt Pro subscription?
  • Unlimited access to all Packt’s 5,000+ eBooks and Videos
  • Early Access content, Progress Tracking, and Assessments
  • 1 Free eBook or Video to download and keep every month after trial
What do I get with an eBook?
  • Download this book in EPUB, PDF, MOBI formats
  • DRM FREE - read and interact with your content when you want, where you want, and how you want
  • Access this title in the Mapt reader
What do I get with Print & eBook?
  • Get a paperback copy of the book delivered to you
  • Download this book in EPUB, PDF, MOBI formats
  • DRM FREE - read and interact with your content when you want, where you want, and how you want
  • Access this title in the Mapt reader
What do I get with a Video?
  • Download this Video course in MP4 format
  • DRM FREE - read and interact with your content when you want, where you want, and how you want
  • Access this title in the Mapt reader
$0.00
$19.60
$34.99
$29.99p/m after trial
RRP $27.99
RRP $34.99
Subscription
eBook
Print + eBook
Start 30 Day Trial

Frequently bought together


Mastering Linux Shell Scripting Book Cover
Mastering Linux Shell Scripting
$ 27.99
$ 19.60
Linux Shell Scripting Bootcamp Book Cover
Linux Shell Scripting Bootcamp
$ 31.99
$ 22.40
Buy 2 for $35.00
Save $24.98
Add to Cart
Subscribe and access every Packt eBook & Video.
 
  • 5,000+ eBooks & Videos
  • 50+ New titles a month
  • 1 Free eBook/Video to keep every month
Start Free Trial
 

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 1 reviews

Read More Reviews

Recommended for You

Linux Shell Scripting Cookbook, Second Edition Book Cover
Linux Shell Scripting Cookbook, Second Edition
$ 26.99
$ 5.40
Learning Docker Book Cover
Learning Docker
$ 39.99
$ 8.00
Mastering Object-oriented Python Book Cover
Mastering Object-oriented Python
$ 26.99
$ 18.90
Python Machine Learning Book Cover
Python Machine Learning
$ 35.99
$ 25.20
Git Version Control Cookbook Book Cover
Git Version Control Cookbook
$ 26.99
$ 18.90
Advanced Tools and Techniques Beyond Base R [Video] Book Cover
Advanced Tools and Techniques Beyond Base R [Video]
$ 124.99
$ 106.25