Mastering Linux Shell Scripting: a practical guide to Linux command-line, Bash scripting, and Shell programming
โ Scribed by Ebrahim, Mokhtar;Mallett, Andrew
- Publisher
- Packt Publishing
- Year
- 2018
- Tongue
- English
- Edition
- 2nd Edition
- Category
- Library
No coin nor oath required. For personal study only.
โฆ Synopsis
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 sysadmin tools.;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.
โฆ Table of Contents
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.
โฆ Subjects
COMPUTERS--Operating Systems--Linux;Python;Electronic books;COMPUTERS -- Operating Systems -- Linux;Linux;UNIX (Computer file);UNIX Shells
๐ SIMILAR VOLUMES
Master the complexities of Bash shell scripting and unlock the power of shell for your enterprise About This Book Identify high-level steps such as verifying user input Using the command line and conditional statements in creating/executing simple shell scripts Create and edit dynamic shell scripts
This book covers the Linux command line commands, Bash Scripting Tricks, Linux Shell Programming Tips and Bash One-liners. The book starts by explaining on the origin of Linux, the people behind its development and also the reason behind development of Linux. The commands for the Linux command lin
This book is for anyone wanting to sharpen their Linux skills. It contains command line tips and tricks designed to make you fast and efficient at the command line.
<h2>Become a Linux Ninja with Command Line Kung Fu!</h2> Do you think you have to lock yourself in a basement reading cryptic man pages for months on end in order to have ninja like command line skills? In reality, if you had someone share their most powerful command line tips, tricks, and patterns