Did you know that Packt offers eBook versions of every book published, with PDF and ePub files available? You can upgrade to the eBook version at www.PacktPub.com and as a print book customer, you are entitled to a discount on the eBook copy. Get in touch with us at service@packtpub.com for more details.
At www.PacktPub.com , you can also read a collection of free technical articles, sign up for a range of free newsletters, and receive exclusive discounts and offers on Packt books and eBooks.
About the authors
Mokhtar Ebrahim started working as a Linux system administrator in 2010. He is responsible for maintaining, securing, and troubleshooting Linux servers for multiple clients around the world. He loves writing shell and Python scripts to automate his work. He writes technical articles on the Like Geeks website about Linux, Python, web development, and server administration. He is a father to a beautiful girl and a husband to a faithful wife.
I would like to thank my wife for helping me with all her efforts to finish this book. Thank you, Doaa, for being a part of that. Also, I would like to thank everyone at Packt for working with me to make sure the book is released. Last but not least, I'd like to thank Brian Fox, the author of the bash shell, for creating such an awesome piece of software; without it, such a book would not exist.
Andrew Mallett is the owner of The Urban Penguin, and he is a comprehensive provider of professional Linux software development, training, and services. Having always been a command-line fan, he feels that so much time can be saved through knowing command-line shortcuts and scripting. TheUrbanPenguin YouTube channel, maintained by Andrew, has well over 800 videos to support this, and he has authored four other Packt titles.
About the reviewer
Sebastiaan Tammer is a Linux enthusiast from The Netherlands. After attaining his BSc in Information Sciences, he graduated with MSc in Business Informatics, both from Utrecht University. His professional career started in Java development before he pivoted into Linux.
He has worked on number of technologies, such as Puppet, Chef, Docker, and Kubernetes. He spends a lot of time in and around his terminal of choice: bash. Whether it is creating complex scripting solutions or just automating simple tasks, there is hardly anything he hasn't done with bash!
I would like to thank my girlfriend, Sanne, for all the help and support she has given me throughout the years. She has had to endure the late nights studying, me fixing stuff (which I had inevitably broken only hours earlier), and my endless storytelling about all those exciting new technologies. Thanks for the enormous amount of patience and love, I could not have done it without you!
What this book covers
, TheWhat and Why of Scripting with Bash, will introduce Linux shells, how to write your first shell script, how to prepare your editor, how to debug your shell script, and some basic bash programming, such as declaring variables, variable scope, and command substitution.
, Creating Interactive Scripts, covers how to read input from the user using read command, how to pass options to your script, how to control the visibility of the entered text, and how to limit the number of entered characters.
, Conditions Attached, will introduce the if statement, the case statement, and other testing command such as else and elif.
, Creating Code Snippets, covers creating and using code snippets using editors, such as vim and Visual Studio Code.
, Alternative Syntax, will discuss advanced testing using [[ and how to perform arithmetic operations.
, Iterating with Loops, will teach you how to use for loops, while loops, and until loops to iterate over simple values and complex values.
, Creating Building Blocks with Functions, will introduce functions and explains how to create a function, list builtin functions, pass parameters to functions, and writing recursive functions.
, Introducing the Stream Editor, will introduce the basics of sed tool to manipulate files, such as adding, replacing deleting, and transforming text.
, Automating Apache Virtual Hosts, contains a practical example of sed and explains how to create virtual hosts automatically using sed.