Learning Linux Shell Scripting – Unleash the power of Shell scripts to solve real-world problems by breaking through the practice of writing tedious code.
Shell scripts are an essential part of any modern operating system, such as UNIX, Linux, Windows, and similar. The scripting language or its syntax may vary from OS to OS; but the fundamental principles remain the same. Shell scripts were initializing the complete product from the basic booting procedure until users logged in and a complete operating system was initialized.
In this Learning Linux Shell Scripting ebook, you will learn about the very basics of Shell scripting to complex, customized automation. By the end of this book, you will be able to confidently use your own Shell scripts for the real-world problems out there. The idea is to be as practical as possible and give you the look and feel of what real-world scripting looks like.
This Learning Linux Shell Scripting book covers bash, the GNU Bourne-Again Shell scripting. You can use the knowledge gained by reading this book for any shell of any of the UNIX flavors or distributions. You will need to take care of a few syntax changes if you are working in other shells, such as Korn, and similar.
What this Learning Linux Shell Scripting book covers
Getting Started and Working with Shell Scripting, you will learn different ways to write and run Shell scripts. You will also learn ways to handle files and directories, and you will learn about working with permissions.
Drilling Deep into Process Management, Job Control, and Automation, you will learn about basic process management. You will learn about command ps and job management using commands such as jobs, fg, bg, kill, and pkill. Later on, you will learn about process monitoring tools: top, iostat, vmstat and sar.
Using Text Processing and Filters in Your Scripts, you will learn about using more, less, head, and tail commands. You will also learn text processing tools such as, cut, paste, comm, and uniq. You will learn about standard input, output, and error. Later on, you will learn about metacharacters and pattern matching using vi and grep.
Working with Commands, you will learn about how shell interprets any command entered on the command line. You will also learn command substitution, separators, and pipes in detail.
Exploring Expressions and Variables, you will learn about variables—environment variables. This will include how to export environment variables, set, shift, read-only variables, command-line arguments, and about creating and handling arrays.
Neat Tricks with Shell Scripting, you will learn about debugging, the here operator, interactive Shell scripts for taking input from the keyboard, and file handling.
Performing Arithmetic in Shell Scripts, you will learn about doing arithmetic operations in various ways, such as using declare, let, expr, and arithmetic expressions. You will also learn about representing numbers in different bases, such as hex, octal, and binary. You will learn about using the bc utility for doing floating point or fractional arithmetic.
Automating Decision Making in Scripts, you will learn about using decision making in scripts working with test, if…else, and switching case. You will also use select for loop with menu. For repeating tasks such as processing lists, you will learn about using for loop, while loop and do while. You will also learn about how to control loops using break and continue statements.
Working with Functions, we will understand about functions in Shell scripts. You will learn about the definition and display of functions by removing the function from the shell. You will also learn about passing arguments to functions, sharing data between functions, declaring local variables in functions, returning results from functions, and running functions in background. You will finally learn about using source and . commands. We will use these commands to use the library of functions.
Using Advanced Functionality in Scripts, you will learn about using traps and signals. You will also learn about creating menus with the help of the dialog utility.
System Startup and Customizing a Linux System, you will learn about Linux system startup from power on until the user login and how to customize a Linux system environment.
Pattern Matching and Regular Expressions with sed and awk, you will learn about regular expressions and using sed (stream editor) and awk for text processing. You will learn about the usage of various commands and options along with a lot of examples for using sed and awk.
Table of Contents
1: GETTING STARTED AND WORKING WITH SHELL SCRIPTING
2: DRILLING DEEP INTO PROCESS MANAGEMENT, JOB CONTROL, AND AUTOMATION
3: USING TEXT PROCESSING AND FILTERS IN YOUR SCRIPTS
4: WORKING WITH COMMANDS
5: EXPLORING EXPRESSIONS AND VARIABLES
6: NEAT TRICKS WITH SHELL SCRIPTING
7: PERFORMING ARITHMETIC OPERATIONS IN SHELL SCRIPTS
8: AUTOMATING DECISION MAKING IN SCRIPTS
9: WORKING WITH FUNCTIONS
10: USING ADVANCED FUNCTIONALITY IN SCRIPTS
11: SYSTEM STARTUP AND CUSTOMIZING A LINUX SYSTEM
12: PATTERN MATCHING AND REGULAR EXPRESSIONS WITH SED AND AWK