售 价:¥
温馨提示:数字商品不支持退换货,不提供源文件,不支持导出打印
为你推荐
Learning Linux Shell Scripting
Table of Contents
Learning Linux Shell Scripting
Credits
About the Author
Acknowledgments
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 color images of this book
Errata
Piracy
Questions
1. Getting Started and Working with Shell Scripting
Comparison of shells
Tasks done by shell
Working in shell
Learning basic Linux commands
Our first script – Hello World
Compiler and interpreter – difference in process
When not to use scripts
Various directories
Working more effectively with shell – basic commands
Working with permissions
Changing file permissions
Command chmod
Technique one – the symbolic method
Technique two – the numeric method
Setting umask
Setuid
Setgid
Sticky bit
Summary
2. Drilling Deep into Process Management, Job Control, and Automation
Introducing process basics
Monitoring processes using ps
Process management
Process monitoring tools – top, iostat, and vmstat
Understanding "at"
Understanding "crontab"
Summary
3. Using Text Processing and Filters in Your Scripts
Text filtering tools
Head and tail
The diff command
The cut command
The paste command
The join command
The uniq command
The comm command
The tr command
IO redirection
File descriptors
Redirection
Brace expansion
Pattern matching with the vi editor
Pattern searching using grep
Summary
4. Working with Commands
Learning shell interpretation of commands
Checking and disabling shell internal commands
The exit status
Command substitution
Command separators
Command1; command2
Command grouping
Logical operators
Command1 & command2
Command1 && command2
Command1 || command2
Pipes
Summary
5. Exploring Expressions and Variables
Understanding variables
Working with environment variables
The local variable and its scope
Exporting variables
Working with read-only variables
Working with command line arguments (special variables, set and shift, getopt)
Understanding set
Understanding shift
Resetting positional parameters
Understanding getopts
Understanding default parameters
Working with arrays
Creating an array and initializing it
Accessing array values
Summary
6. Neat Tricks with Shell Scripting
Interactive Shell scripts – reading user input
Summarizing the read command with options
The here document and the << operator
The here operator with the sort command
The here operator with the wc command
The utility ed and here operator
A script for sending messages to all logged-in users
Using the << here operator for FTP usage and data transfer
Turning off variable substitution
The here string and the <<< operator
File handling
Introducing file handling
Using exec to assign file descriptor (fd) to file
Understanding the opening, writing, and closing of a file
Understanding reading from a file
Understanding reading and writing to a file
Using command read on file descriptor (fd)
Reading from one file and writing to another file
Displaying the file descriptor information from the /proc folder
File handling – reading line by line
Executing the command and storing the results in a file
Summarizing usage of the exec command
Debugging
Debugging mode – disabling the shell (option -n)
Debugging mode – displaying commands (option -v)
Debugging mode – the tracing execution (option -x)
Summarizing the debugging options for the Bash shell
Using the set command
Summary of debugging options for set command
The vi editor setting for debugging
Good practices for Shell scripts
Summary
7. Performing Arithmetic Operations in Shell Scripts
Using a command declare for arithmetic
Listing integers
Using the let command for arithmetic
Using the expr command for arithmetic
Using an arithmetic expansion
Binary, octal, and hex arithmetic operations
A floating-point arithmetic
Summary
8. Automating Decision Making in Scripts
Checking the exit status of commands
Understanding the test command
Using the test command with single brackets
Using the test command with double brackets
String comparison options for the test command
Numerical comparison operators for the test command
File test options for the test command
File testing binary operators
Logical test operators
Conditional constructs – if else
Numerical handling if constructs
Using the command exit and the ? variable
String handling with the if construct
Checking for null values
File handling with the if command
Multiple test commands and if constructs
The if/elif/else command
The null command
Switching case
Implementing simple menus with select
Looping with the for command
Exiting from the current loop iteration with the continue command
Exiting from a loop with a break
Working with the do while loop
Using until
Piping the output of a loop to a Linux command
Running loops in the background
The IFS and loops
Summary
9. Working with Functions
Understanding functions
Displaying functions
Removing functions
Passing arguments or parameters to functions
Sharing the data by many functions
Declaring local variables in functions
Returning information from functions
Returning a word or string from a function
Running functions in the background
Command source and period (.)
Creating a library of functions
Summary
10. Using Advanced Functionality in Scripts
Understanding signals and traps
Using the trap command
Ignoring signals
Resetting signals
Listing traps
Using traps in function
Running scripts or processes even if the user logs out
Creating dialog boxes with the dialog utility
Creating a message box (msgbox)
Creating a message box (msgbox) with a title
The yes/no box (yesno)
The input box (inputbox)
The textbox (textbox)
A password box
The menu box (menu)
The checklist box (checklist)
The radiolist box (radiolist)
The progress meter box (gauge)
Summary
11. System Startup and Customizing a Linux System
System startup, inittab, and run levels
The kernel startup and init process
Understanding run levels
System initialization boot scripts
User initialization scripts
Systemwide settings scripts
User level settings – default files
Summary
12. Pattern Matching and Regular Expressions with sed and awk
The basics of regular expressions
sed – noninteractive stream editor
Understanding sed
Understanding regular expression usage in sed
Addressing in sed
How to modify a file with sed
Printing – the p command
Deleting – the d command
Substitution – the s command
Range of selected lines: the comma
Multiple edits – the e command
Reading from files – the r command
Writing to files – the w command
Appending – the a command
Inserting – the i command
Changing – the c command
Transform – the y command
Quit – the q command
Holding and getting – the h and g commands
Holding and exchanging – the h and x commands
sed scripting
Using awk
The meaning of awk
Using awk
Input from files
Input from commands
How awk works
awk commands from within a file
Records and fields
Records
The record separator
The $0 variable
The NR variable
Fields
Field separators
The input field separator
Patterns and actions
Patterns
Actions
Regular expressions
Writing the awk script file
Using variables in awk
Decision making using an if statement
Using the for loop
Using the while loop
Using the do while loop
Summary
Index
买过这本书的人还买过
读了这本书的人还在读
同类图书排行榜