Linux Shell Scripting Essentials
eBook - ePub

Linux Shell Scripting Essentials

Sinny Kumari

Buch teilen
  1. 282 Seiten
  2. English
  3. ePUB (handyfreundlich)
  4. Über iOS und Android verfügbar
eBook - ePub

Linux Shell Scripting Essentials

Sinny Kumari

Angaben zum Buch
Buchvorschau
Inhaltsverzeichnis
Quellenangaben

Über dieses Buch

Learn shell scripting to solve complex shell-related problems and to efficiently automate your day-to-day tasks

About This Book

  • Familiarize yourself with the terminal by learning about powerful shell features
  • Automate tasks by writing shell scripts for repetitive work
  • Packed with easy-to-follow, hands-on examples to help you write any type of shell script with confidence

Who This Book Is For

This book is aimed at administrators and those who have a basic knowledge of shell scripting and who want to learn how to get the most out of writing shell scripts.

What You Will Learn

  • Write effective shell scripts easily
  • Perform search operations and manipulate large text data with a single shell command
  • Modularize reusable shell scripts by creating shell libraries
  • Redirect input, output, and errors of a command or script execution to other streams
  • Debug code with different shell debugging techniques to make your scripts bug-free
  • Manage processes, along with the environment variables needed to execute them properly
  • Execute and embed other languages in your scripts
  • Manage creation, deletion, and search operations in files

In Detail

Shell scripting is a quick method to prototype complex applications or problems. Shell scripts are a collection of commands to automate tasks, usually those for which the user has a repeated need, when working on Linux-based systems. Using simple commands or a combination of them in a shell can solve complex problems easily.

This book starts with the basics, including essential commands that can be executed on Linux systems to perform tasks within a few nanoseconds. You'll learn to use outputs from commands and transform them to show the data you require. Discover how to write shell scripts easily, execute script files, debug, and handle errors.

Next, you'll explore environment variables in shell programming and learn how to customize them and add a new environment. Finally, the book walks you through processes and how these interact with your shell scripts, along with how to use scripts to automate tasks and how to embed other languages and execute them.

Style and approach

This book is a pragmatic guide to writing efficient shell programs, complete with hands-on examples and tips.

Häufig gestellte Fragen

Wie kann ich mein Abo kündigen?
Gehe einfach zum Kontobereich in den Einstellungen und klicke auf „Abo kündigen“ – ganz einfach. Nachdem du gekündigt hast, bleibt deine Mitgliedschaft für den verbleibenden Abozeitraum, den du bereits bezahlt hast, aktiv. Mehr Informationen hier.
(Wie) Kann ich Bücher herunterladen?
Derzeit stehen all unsere auf Mobilgeräte reagierenden ePub-Bücher zum Download über die App zur Verfügung. Die meisten unserer PDFs stehen ebenfalls zum Download bereit; wir arbeiten daran, auch die übrigen PDFs zum Download anzubieten, bei denen dies aktuell noch nicht möglich ist. Weitere Informationen hier.
Welcher Unterschied besteht bei den Preisen zwischen den Aboplänen?
Mit beiden Aboplänen erhältst du vollen Zugang zur Bibliothek und allen Funktionen von Perlego. Die einzigen Unterschiede bestehen im Preis und dem Abozeitraum: Mit dem Jahresabo sparst du auf 12 Monate gerechnet im Vergleich zum Monatsabo rund 30 %.
Was ist Perlego?
Wir sind ein Online-Abodienst für Lehrbücher, bei dem du für weniger als den Preis eines einzelnen Buches pro Monat Zugang zu einer ganzen Online-Bibliothek erhältst. Mit über 1 Million Büchern zu über 1.000 verschiedenen Themen haben wir bestimmt alles, was du brauchst! Weitere Informationen hier.
Unterstützt Perlego Text-zu-Sprache?
Achte auf das Symbol zum Vorlesen in deinem nächsten Buch, um zu sehen, ob du es dir auch anhören kannst. Bei diesem Tool wird dir Text laut vorgelesen, wobei der Text beim Vorlesen auch grafisch hervorgehoben wird. Du kannst das Vorlesen jederzeit anhalten, beschleunigen und verlangsamen. Weitere Informationen hier.
Ist Linux Shell Scripting Essentials als Online-PDF/ePub verfügbar?
Ja, du hast Zugang zu Linux Shell Scripting Essentials von Sinny Kumari im PDF- und/oder ePub-Format sowie zu anderen beliebten Büchern aus Computer Science & Operating Systems. Aus unserem Katalog stehen dir über 1 Million Bücher zur Verfügung.

Information

Jahr
2015
ISBN
9781785284441

Linux Shell Scripting Essentials


Table of Contents

Linux Shell Scripting Essentials
Credits
About the Author
About the Reviewers
www.PacktPub.com
Support files, eBooks, discount offers, and more
Why subscribe?
Free access for Packt account holders
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. The Beginning of the Scripting Journey
Hello World in shell
Interacting with shell
Let's make it scripted
Define variables of choice
Nomenclature
Assigning a value
Accessing a value
Constant variables
Reading variables from a user input
Builtin shell variables
Operators
The assignment operator
Arithmetic operators
Logical operators
Comparison operators
Shell expansions
~ (Tilde)
* (Asterisk)
? (Question mark)
[ ] (Square brackets)
{ } (Curly brackets)
Construct commands using eval
Make bash behave using set
Exit on the first failure
Enabling/disabling symbolic link's resolution path
Setting/unsetting variables
Summary
2. Getting Hands-on with I/O, Redirection Pipes, and Filters
Standard I/O and error streams
File descriptors
Redirecting the standard I/O and error streams
Redirecting standard output
Redirecting standard input
Redirecting standard errors
Multiple redirection
Pipe and pipelines – connecting commands
Pipe
Pipeline
Regular expressions
Regular expression metacharacters
Character ranges and classes
Character ranges
Matching dates in mm-dd-yyyy format
Matching a valid month
Matching a valid day
Matching the valid year in a date
Combining valid months, days, and years regex to form valid dates
Regex for a valid shell variable
Filtering an output using grep
Syntax
Looking for a pattern in a file
Looking for a pattern in multiple files
A few more grep usages
Searching in a binary file
Searching in a directory
Excluding files/directories from a search
Display a filename with a matching pattern
Matching an exact word
Editing output using sed
String substitution using s
Multiple substitutions
Duplicating a stream using tee
Writing an output to stdout and appending to a file
Sending an output to multiple commands
Sorting and finding unique text
Sorting an input text
Sorting a single file
Redirecting output to sort
Filtering unique elements
Unique elements in a file
Character-based translation using tr
Deleting input characters
Squeezing to a single occurrence
Inverting a character set to be translated
Filtering based on lines—head and tail
Printing lines using head
Printing the first few lines
Printing the first few bytes
Printing lines using tail
Checking log entries
Finding any line in a file
The Cut-based selection
Cutting across columns
Text selection in files
Summary
3. Effective Script Writing
Exiting from scripts and exit codes
Exit codes
Exit codes with a special meaning
Script with exit codes
Testing expressions with a test
File checks
Arithmetic checks
String checks
Expression checks
Using conditional statements with if and else
Simple if and else
The if, elif, and else statements
Nested if
Indexed arrays and associative arrays
Indexed arrays
Array declaration and value assignment
Operations on arrays
The associative array
The declaration and value assignment
Operations on arrays
Looping around with for
Simple iteration
Iterating over a command output
Specifying a range to the for loop
Small and sweet for loop
The select, while, and until loops
Loop using select
The while loop
The until loop
Switch to my choice
Passing stdout as a parameter using xargs
Basic operations with xargs
Using xargs to find a file with the maximum size
Archiving files with a given pattern
Using funct...

Inhaltsverzeichnis