Linux Shell Scripting Bootcamp
eBook - ePub

Linux Shell Scripting Bootcamp

  1. 208 pages
  2. English
  3. ePUB (mobile friendly)
  4. Available on iOS & Android
eBook - ePub

Linux Shell Scripting Bootcamp

About this book

A quick and straightforward approach to writing shell scripts to accomplish different types of tasks on a Linux system.About This Book• Understand expressions and variables and how to use them practically• Familiarize yourself with the various text filtering tools available in Linux• A fast-paced and concise guide that gets you well versed with linux shell scripting.Who This Book Is ForThis book is for both GNU/Linux users who want to do amazing things with the shell and for advanced users looking for ways to make their lives with the shell more productive.What You Will Learn• Get acquainted with the basics of a shell script to serve as a refresher for more advanced topics• Learn different ways to create and run a script• Discuss the passing and verification of parameters, along with the verification of other items.• Understand the different forms of conditions and loops, and go over the sleep command in detail• Learn about different ways to handle the reporting of return codes• Create an interactive script by reading the keyboard and use subroutines and interrupts• Create scripts to perform backups and go over the use of encryption tools and checksums• Use wget and curl in scripts to get data directly from the InternetIn DetailLinux Shell Scripting Bootcamp is all about learning the essentials of script creation, validating parameters, and checking for the existence of files and other items needed by the script.We will use scripts to explore iterative operations using loops and learn different types of loop statements, with their differences. Along with this, we will also create a numbered backup script for backup files.Further, you will get well-versed with how variables work on a Linux system and how they relate to scripts. You'll also learn how to create and call subroutines in a script and create interactive scripts. The most important archive commands, zip and tar, are also discussed for performing backups. Later, you will dive deeper by understanding the use of wget and curl scripts and the use of checksum and file encryption in further chapters.Finally, you will learn how to debug scripts and scripting best practices that will enable you to write a great code every time! By the end of the book, you will be able to write shell scripts that can dig data from the web and process it efficiently.Style and approachThis book is all about fast and intensive learning. This means we don't waste time in helping readers get started. The new content is basically about filling in with highly-effective examples to build new things, solving problems in newer and unseen ways, and solving real-world examples.

Frequently asked questions

Yes, you can cancel anytime from the Subscription tab in your account settings on the Perlego website. Your subscription will stay active until the end of your current billing period. Learn how to cancel your subscription.
No, books cannot be downloaded as external files, such as PDFs, for use outside of Perlego. However, you can download books within the Perlego app for offline reading on mobile or tablet. Learn more here.
Perlego offers two plans: Essential and Complete
  • Essential is ideal for learners and professionals who enjoy exploring a wide range of subjects. Access the Essential Library with 800,000+ trusted titles and best-sellers across business, personal growth, and the humanities. Includes unlimited reading time and Standard Read Aloud voice.
  • Complete: Perfect for advanced learners and researchers needing full, unrestricted access. Unlock 1.4M+ books across hundreds of subjects, including academic and specialized titles. The Complete Plan also includes advanced features like Premium Read Aloud and Research Assistant.
Both plans are available with monthly, semester, or annual billing cycles.
We are an online textbook subscription service, where you can get access to an entire online library for less than the price of a single book per month. With over 1 million books across 1000+ topics, we’ve got you covered! Learn more here.
Look out for the read-aloud symbol on your next book to see if you can listen to it. The read-aloud tool reads text aloud for you, highlighting the text as it is being read. You can pause it, speed it up and slow it down. Learn more here.
Yes! You can use the Perlego app on both iOS or Android devices to read anytime, anywhere — even offline. Perfect for commutes or when you’re on the go.
Please note we cannot support devices running on iOS 13 and Android 7 or earlier. Learn more about using the app.
Yes, you can access Linux Shell Scripting Bootcamp by James Kent Lewis in PDF and/or ePUB format, as well as other popular books in Computer Science & Computer Networking. We have over one million books available in our catalogue for you to explore.

Information

Linux Shell Scripting Bootcamp


Table of Contents

Linux Shell Scripting Bootcamp
Credits
About the Author
Acknowledgement
About the Reviewer
www.PacktPub.com
eBooks, discount offers, and more
Why subscribe?
Customer Feedback
Preface
What this book covers
What you need for this book
Who this book is for
Conventions
Reader feedback
Customer support
Downloading the example code
Errata
Piracy
Questions
1. Getting Started with Shell Scripting
Getting started
Using a good text editor
Demonstrating the use of scripts
Chapter 1 - Script 1
Chapter 1 - Script 2
Chapter 1 - Script 3
Chapter 1 - Script 4
Chapter 1 - Script 5
Chapter 1 - Script 6
Summary
2. Working with Variables
Using variables in scripts
Chapter 2 - Script 1
Validating parameters using conditional statements
Chapter 2 - Script 2
Comparison operators for strings
Chapter 2 - Script 3
Chapter 2 - Script 4
Chapter 2 - Script 5
Environment variables
Chapter 2 - Script 6
Chapter 2 - Script 7
Summary
3. Using Loops and the sleep Command
Using loops
Chapter 3 - Script 1
Chapter 3 - Script 2
Chapter 3 - Script 3
Screen manipulation
Chapter 3 - Script 4
Chapter 3 - Script 5
Indenting your code
Chapter 3 - Script 6
Using the for statement
Chapter 3 - Script 7
Chapter 3 - Script 8
Leaving a loop early
Chapter 3 - Script 9
The sleep command
Chapter 3 - Script 10
Chapter 3 - Script 11
Watching a process
Chapter 3 - Script 12
Creating numbered backup files
Chapter 3 – Script 13
Summary
4. Creating and Calling Subroutines
Clearing the screen
Chapter 4 - Script 1
File redirection
Command piping
Chapter 4 - Script 2
Chapter 4 - Script 3
Subroutines
Chapter 4 - Script 4
Using parameters
Chapter 4 - Script 5
Chapter 4 - Script 6
Making a current backup of your work
Chapter 4 – Script 7
Summary
5. Creating Interactive Scripts
Chapter 5 - Script 1
Chapter 5 - Script 2
Chapter 5 - Script 3
Chapter 5 - Script 4
Chapter 5 - Script 5
Chapter 5 - Script 6
Chapter 5 - Script 7
Chapter 5 - Script 8
Summary
6. Automating Tasks with Scripts
Chapter 6 - Script 1
Chapter 6 - Script 2
Chapter 6 - Script 3
Chapter 6 - Script 4
Cron
Chapter 6 - Script 5
Chapter 6 - Script 6
Chapter 6 - Script 7
Summary
7. Working with Files
Writing files
Chapter 7 - Script 1
Reading files
Chapter 7 - Script 2
Chapter 7 - Script 3
Chapter 7 - Script 4
Reading and writing files
Chapter 7 - Script 5
Reading and writing files interactively
Chapter 7 - Script 6
File checksums
File encryption
Chapter 7 - Script 7
Summary
8. Working with wget and curl
Introducing the wget program
wget options
wget return codes
wget configuration files
Chapter 8 - Script 1
wget and recursion
wget options
curl
curl options
Chapter 8 - Script 2
Summary
9. Debugging Scripts
Syntax errors
Chapter 9 - Script 1
Chapter 9 - Script 2
Automatic backups
More syntax errors
Chapter 9 - Script 3
Logic errors
Chapter 9 - Script 4
Using set to debug scripts
Chapter 9 - Script 5 and Script 6
Chapter 9 - Script 7
Chapter 9 - Script 8
Chapter 9 - Script 9
Summary
10. Scripting Best Practices
Verifying backups
ssh and scp
Find and use a good text editor
Environment variables and aliases
ssh prompt
Testing an archive
Progress indicator
Chapter 10 - Script 1
Creating new commands from a template
Chapter 10 – Script 2
Alerting the user
Chapter 10 – Script 3
Summary
Index

Linux Shell Scripting Bootcamp

Copyright © 2017 Packt Publishing
All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews.
Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the author, nor Packt Publishing, and its dealers and distributors will be held liable for any damages caused or alleged to be caused directly or indirectly by this book.
Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information.
First published: July 2017
Production reference: 1170717
Published by Packt Publishing Ltd.
Livery Place
35 Livery Street
Birmingham B3 2PB, UK.
ISBN 978-1-78728-110-3
www.packtpub.com

Credits

Author
James Kent Lewis
Reviewer
Thushara Jayawardena
Commissioning Editor
Pratik Shah
Acquisition Editor
Namrata Patil
Content Development Editor
Amrita Noronha
Technical Editor
Jovita Alva
Copy Editor
SAFIS
Laxmi Subramanian
Project Coordinator
Shweta H Birwatkar
Proofreader
SAFIS
Laxmi Subramanian
Indexer
Pratik Shirodkar
Graphics
Tania Dutta
Production Coordinator
Arvindkumar Gupta
Cover Work
Arvindkumar Gupta

About the Author

James Kent Lewis has been in the computer industry for over 35 years. He started out writing basic programs in high school and used punch cards in college for...

Table of contents

  1. Linux Shell Scripting Bootcamp