万本电子书0元读

万本电子书0元读

顶部广告

Mastering Linux Shell Scripting电子书

售       价:¥

6人正在读 | 0人评论 9.8

作       者:Mokhtar Ebrahim,Andrew Mallett

出  版  社:Packt Publishing

出版时间:2018-04-19

字       数:25.6万

所属分类: 进口书 > 外文原版书 > 电脑/网络

温馨提示:数字商品不支持退换货,不提供源文件,不支持导出打印

为你推荐

  • 读书简介
  • 目录
  • 累计评论(0条)
  • 读书简介
  • 目录
  • 累计评论(0条)
Master the complexities of Bash shell scripting and unlock the power of shell for your enterprise About This Book ? Identify high-level steps such as verifying user input ? Using the command line and conditional statements in creating/executing simple shell scripts ? Create and edit dynamic shell scripts to manage complex and repetitive tasks ? Leverage the command-line to bypass GUI and automate common tasks Who This Book Is For If you are a Linux administrator or a system administrator and are interested in automating tasks in your daily lives, saving time and effort, this book is for you. Basic shell scripting and command-line experience will be required. Familiarity with the tasks you need to automate will be helpful. What You Will Learn ? Make, execute, and debug your first Bash script ? Create interactive scripts that prompt for user input ? Foster menu structures for operators with little command-line experience ? Develop scripts that dynamically edit web configuration files to produce a new virtual host ? Write scripts that use AWK to search and reports on log files ? Draft effective scripts using functions as building blocks, reducing maintenance and build time ? Make informed choices by comparing different script languages such as Python with BASH In Detail In this book, you’ll discover everything you need to know to master shell scripting and make informed choices about the elements you employ. Grab your favorite editor and start writing your best Bash scripts step by step. Get to grips with the fundamentals of creating and running a script in normal mode, and in debug mode. Learn about various conditional statements' code snippets, and realize the power of repetition and loops in your shell script. You will also learn to write complex shell scripts. This book will also deep dive into file system administration, directories, and system administration like networking, process management, user authentications, and package installation and regular expressions. Towards the end of the book, you will learn how to use Python as a BASH Scripting alternative. By the end of this book, you will know shell scripts at the snap of your fingers and will be able to automate and communicate with your system with keyboard expressions. Style and approach The book will capture your attention and keep you engaged with the simplicity and clarity of each explanation. Every step is accompanied by screenshots so you can cross-check the results before moving on.
目录展开

Title Page

Copyright and Credits

Mastering Linux Shell Scripting Second Edition

Packt Upsell

Why subscribe?

PacktPub.com

Contributors

About the authors

About the reviewer

Packt is searching for authors like you

Preface

Who this book is for

What this book covers

To get the most out of this book

Download the example code files

Download the color images

Conventions used

Get in touch

Reviews

The What and Why of Scripting with Bash

Technical requirements

Types of Linux shells

What is bash scripting?

The bash command hierarchy

Command type

Command PATH

Preparing text editors for scripting

Configuring vim

Configuring nano

Configuring gedit

Creating and executing scripts

Hello World!

Executing the script

Checking the exit status

Ensuring a unique name

Hello Dolly!

Running the script with arguments

The importance of correct quotes

Printing the script name

Declaring variables

User-defined variables

Environment variables

Variable scope

Command substitution

Debugging your scripts

Summary

Questions

Further reading

Creating Interactive Scripts

Technical requirements

Using echo with options

Basic script using read

Script comments

Enhancing scripts with read prompts

Limiting the number of entered characters

Controlling the visibility of the entered text

Passing options

Passing parameters with options

Read options values

Try to be standard

Enhancing learning with simple scripts

Backing-up with scripts

Connecting to a server

Version 1 – ping

Version 2 – SSH

Version 3 – MySQL/MariaDB

Reading files

Summary

Questions

Further reading

Conditions Attached

Technical requirements

Simple decision paths using command-line lists

Verifying user input with lists

Using the test shell built-in

Testing strings

Testing integers

Testing file types

Creating conditional statements using if

Extending if with else

Test command with the if command

Checking strings

Checking files and directories

Checking numbers

Combining tests

More conditions with elif

Creating the backup2.sh using elif

Using case statements

Recipe – building a frontend with grep

Summary

Questions

Further reading

Creating Code Snippets

Technical requirements

Abbreviations

Using code snippets

Bringing color to the Terminal

Creating snippets using VS Code

Summary

Questions

Further reading

Alternative Syntax

Technical requirement

Recapping the test command

Testing files

Adding logic

Square brackets as not seen before

Providing parameter defaults

Variables

Special parameters

Setting defaults

When in doubt – quote!

Advanced tests using [[

White space

Other advanced features

Pattern matching

Regular expressions

Regular expression script

Arithmetic operations using ((

Simple math

Parameter manipulation

Standard arithmetic tests

Summary

Questions

Further reading

Iterating with Loops

Technical requirement

for loops

Advanced for loops

The IFS

Counting directories and files

C-style for loops

Nested loops

Redirecting loop output

Controlling the loop

while loops and until loops

Reading input from files

Creating operator menus

Summary

Questions

Further reading

Creating Building Blocks with Functions

Technical requirements

Introducing functions

Passing parameters to functions

Passing arrays

Variable scope

Returning values from functions

Recursive functions

Using functions in menus

Summary

Questions

Further reading

Introducing the Stream Editor

Technical requirements

Using grep to display text

Displaying received data on an interface

Displaying user account data

Listing the number of CPUs in a system

Parsing CSV files

The CSV file

Isolating catalog entries

Understanding the basics of sed

The substitute command

Global replacement

Limiting substitution

Editing the file

Other sed commands

The delete command

The insert and append commands

The change command

The transform command

Multiple sed commands

Summary

Questions

Further reading

Automating Apache Virtual Hosts

Technical requirements

Apache name-based Virtual Hosts

Creating the virtual host template

First steps

Isolating lines

sed script files

Automating virtual host creation

Prompting for data during site creation

Summary

Questions

Further reading

AWK Fundamentals

Technical requirements

The history behind AWK

Displaying and filtering content from files

AWK variables

User-defined variables

Conditional statements

The if command

while loops

for loops

Formatting output

Further filtering to display users by UID

AWK control files

Built-in functions

Summary

Questions

Further reading

Regular Expressions

Technical requirements

Regular expression engines

Defining BRE patterns

Anchor characters

The dot character

The character class

Ranges of characters

Special character classes

The asterisk

Defining ERE patterns

The question mark

The plus sign

Curly braces

The pipe character

Expression grouping

Using grep

Summary

Questions

Further reading

Summarizing Logs with AWK

Technical requirements

The HTTPD log file format

Displaying data from web logs

Selecting entries by date

Summarizing 404 errors

Summarizing HTTP access codes

Resources hits

Identify image hotlinking

Displaying the highest ranking IP address

Displaying the browser data

Working with email logs

Summary

Questions

Further reading

A Better lastlog with AWK

Technical requirements

Using AWK ranges to exclude data

The lastlog command

Horizontally filtering rows with AWK

Counting matched rows

Conditions based on the number of fields

Manipulating the AWK record separator to report on XML data

Apache Virtual Hosts

XML catalog

Summary

Questions

Further reading

Using Python as a Bash Scripting Alternative

Technical requirements

What is Python?

Saying Hello World the Python way

Pythonic arguments

Supplying arguments

Counting arguments

Significant whitespace

Reading user input

Using Python to write to files

String manipulation

Summary

Questions

Further reading

Assessments

Chapter 1

Chapter 2

Chapter 3

Chapter 4

Chapter 5

Chapter 6

Chapter 7

Chapter 8

Chapter 9

Chapter 10

Chapter 11

Chapter 12

Chapter 13

Chapter 14

Other Books You May Enjoy

Leave a review - let other readers know what you think

累计评论(0条) 0个书友正在讨论这本书 发表评论

发表评论

发表评论,分享你的想法吧!

买过这本书的人还买过

读了这本书的人还在读

回顶部