售 价:¥
温馨提示:数字商品不支持退换货,不提供源文件,不支持导出打印
为你推荐
Mastering Linux Shell Scripting
Table of Contents
Mastering Linux Shell Scripting
Credits
About the Author
About the Reviewer
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
Downloading the color images of this book
Errata
Piracy
Questions
1. What and Why of Scripting with Bash
Bash vulnerabilities
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
Debugging your scripts
Summary
2. Creating Interactive Scripts
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 entered text
Enhancing learning with simple scripts
Backing-up with scripts
Connecting to a server
Version 1 – ping
Version 2 – SSH
Version 3 – MySQL/MariaDB
Summary
3. Conditions Attached
Simple decision paths using command-line lists
Verifying user input with lists
Using the test shell builtin
Testing strings
Testing integers
Testing file types
Creating conditional statements using if
Extending if with else
More conditions with elif
Creating the backup2.sh using elif
Using case statements
Script – building a front-end with grep
Summary
4. Creating Code Snippets
Abbreviations
Using code snippets
Bringing color to the terminal
Summary
5. Alternative Syntax
Recapping test
Testing files
Adding logic
Square brackets as not seen before
Providing parameter defaults
Variables
Special parameters
Setting defaults
When in doubt – Quote!
Advanced test using [[
Whitespace
Other advanced features
Pattern matching
Regular expressions
Regular expression script
Arithmetic operations using ((
Simple math
Parameter manipulation
Standard arithmetic tests
Summary
6. Iterating with Loops
For loops
Controlling the loop
While loops and until loops
Reading input from files
Creating operator menus
Summary
7. Creating Building Blocks with Functions
Introducing functions
Passing parameters to functions
Returning values from functions
Using functions in menus
Summary
8. Introducing sed
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
Using regular expressions
Working with alternate spellings
How many words have four consecutive vowels?
RE anchors
Understanding the basics of sed
Substituting command
Editing the file
Summary
9. Automating Apache Virtual Hosts
Apache name-based Virtual Hosts
Creating the Virtual Hosts template
First steps
Isolating lines
sed script files
Automating Virtual Host creation
Prompting for data during site creation
Summary
10. Awk Fundamentals
The history behind awk
Displaying and filtering content from files
Formatting output
Further filtering to display users by UID
Awk control files
Summary
11. Summarizing Logs with Awk
The HTTPD log file format
Displaying data from web logs
Selecting entries by date
Summarizing 404 errors
Summarizing HTTP access codes
Displaying the highest ranking IP address
Displaying the browser data
Working with e-mail logs
Summary
12. A Better lastlog with Awk
Using awk ranges to exclude data
The lastlog command
Horizontal 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
13. Using Perl as a Bash Scripting Alternative
What is Perl?
Hello World
Perl arrays
Program name?
Argument arrays
Counting elements in an array
Looping through an array
Creating arrays
Conditional statements in Perl
Replacing command line lists
If and unless
Using functions within Perl
Prompt for user input
Creating the function
Summary
14. Using Python as a Bash Scripting Alternative
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
Summary
Index
买过这本书的人还买过
读了这本书的人还在读
同类图书排行榜