Linux Shell Scripting Essentials
eBook - ePub

Linux Shell Scripting Essentials

Sinny Kumari

Compartir libro
  1. 282 páginas
  2. English
  3. ePUB (apto para móviles)
  4. Disponible en iOS y Android
eBook - ePub

Linux Shell Scripting Essentials

Sinny Kumari

Detalles del libro
Vista previa del libro
Índice
Citas

Información del libro

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.

Preguntas frecuentes

¿Cómo cancelo mi suscripción?
Simplemente, dirígete a la sección ajustes de la cuenta y haz clic en «Cancelar suscripción». Así de sencillo. Después de cancelar tu suscripción, esta permanecerá activa el tiempo restante que hayas pagado. Obtén más información aquí.
¿Cómo descargo los libros?
Por el momento, todos nuestros libros ePub adaptables a dispositivos móviles se pueden descargar a través de la aplicación. La mayor parte de nuestros PDF también se puede descargar y ya estamos trabajando para que el resto también sea descargable. Obtén más información aquí.
¿En qué se diferencian los planes de precios?
Ambos planes te permiten acceder por completo a la biblioteca y a todas las funciones de Perlego. Las únicas diferencias son el precio y el período de suscripción: con el plan anual ahorrarás en torno a un 30 % en comparación con 12 meses de un plan mensual.
¿Qué es Perlego?
Somos un servicio de suscripción de libros de texto en línea que te permite acceder a toda una biblioteca en línea por menos de lo que cuesta un libro al mes. Con más de un millón de libros sobre más de 1000 categorías, ¡tenemos todo lo que necesitas! Obtén más información aquí.
¿Perlego ofrece la función de texto a voz?
Busca el símbolo de lectura en voz alta en tu próximo libro para ver si puedes escucharlo. La herramienta de lectura en voz alta lee el texto en voz alta por ti, resaltando el texto a medida que se lee. Puedes pausarla, acelerarla y ralentizarla. Obtén más información aquí.
¿Es Linux Shell Scripting Essentials un PDF/ePUB en línea?
Sí, puedes acceder a Linux Shell Scripting Essentials de Sinny Kumari en formato PDF o ePUB, así como a otros libros populares de Computer Science y Operating Systems. Tenemos más de un millón de libros disponibles en nuestro catálogo para que explores.

Información

Año
2015
ISBN
9781785284441
Edición
1

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...

Índice