Bash quick start guide : get up and running with Shell scripting with Bash.
Bash and shell script programming is central to using Linux, but it has many peculiar properties that are hard to understand and unfamiliar to many programmers, with a lot of misleading and even risky information online. Bash Quick Start tackles these problems head on, and shows you the best practic...
Clasificación: | Libro Electrónico |
---|---|
Autor principal: | |
Formato: | Electrónico eBook |
Idioma: | Inglés |
Publicado: |
Birmingham :
Packt Publishing Ltd,
2018.
|
Temas: | |
Acceso en línea: | Texto completo |
Tabla de Contenidos:
- Cover
- Title Page
- Copyright and Credits
- Dedication
- Packt Upsell
- Contributors
- Table of Contents
- Preface
- Chapter 1: What is Bash?
- What Bash is and is not
- Getting Bash
- Checking Bash is running
- Switching the login shell to Bash
- Identifying the Bash version number
- Upgrading Bash on macOS X
- Understanding Bash features
- POSIX shell script features
- Bash-specific features
- Do I need Bash?
- Choosing when to apply Bash
- Choosing when to avoid Bash
- Getting help with Bash
- Summary
- Chapter 2: Bash Command Structure
- Using Bash interactively
- Interactive key bindings
- Simple commands
- Shell metacharacters
- Quoting
- Escaping
- Single quotes
- Double quotes
- Quote concatenation
- Running commands in sequence
- Exit values
- Stopping a command list on error
- Running a command in the background
- Summary
- Chapter 3: Essential Commands
- Distinguishing command types
- Essential Bash builtin commands
- The type command
- The echo command
- The printf command
- The pwd command
- Tilde paths
- The cd command
- Changing the directory in scripts
- The set command
- The declare command
- The test, [, and [[commands
- Essential system commands
- The ls command
- Getting filename lists without ls
- The mv command
- The cp command
- The rm and rmdir commands
- The grep command
- The cut command
- The wc command
- Getting file sizes with wc or du
- The find command
- Executing commands for each result
- A note about find and xargs
- The sort and uniq commands
- Summary
- Chapter 4: Input, Output, and Redirection
- Redirecting output
- Redirection paths
- Avoiding overwrites
- Appending to files
- Understanding created file permissions
- Choosing permissions for created files
- Redirecting errors
- Combining errors with output.
- Blocking errors completely
- Sending output to more than one place
- Redirecting input
- Using a long string as input with here-documents
- Using pipes
- Adding file contents to a stream
- Piping output from multiple programs
- Filtering programs
- The sed stream editor
- The AWK programming language
- Summary
- Chapter 5: Variables and Patterns
- Using variables
- Listing variables
- Naming variables
- Variable name case
- Clearing variables
- Environment variables
- Calling programs with environment variables
- Expanding variables
- Reading a value into a variable
- Getting command output in variables
- Parameter expansion forms
- Specifying default values
- String chopping
- Extracting substrings
- Getting string length
- Substituting strings
- Changing case
- Combining parameter expansion forms
- Doing math in Bash
- Fixed or floating-point arithmetic
- Using globs
- Configuring globbing behavior
- Including dot files, but excluding dot and dot-dot
- Expanding to nothing
- Case-insensitive globbing
- Extended globbing
- Using arrays
- Glob expansion in arrays
- Associative arrays
- Summary
- Chapter 6: Loops and Conditionals
- Using the if keyword
- Using the test command
- Using the [command
- Using the [[keyword
- Arithmetic conditions
- Switching with the case keyword
- Looping over shell words with for
- Skipping an iteration
- Ending the loop
- Misuse of for loops
- Using Bash's C-style for loops
- Using while loops
- Infinite loops
- Reading data line by line
- Field splitting
- Saving fields into arrays
- Choosing the splitting character
- Disabling whitespace trimming
- Reading process output
- Avoiding subshell problems
- Avoiding input problems with ssh
- Summary
- Chapter 7: Scripts, Functions, and Aliases
- Aliases
- Defining new aliases.
- Understanding shortcomings with aliases
- Functions
- Defining functions
- Passing arguments to functions
- Using
- to separate options from filenames
- Getting all the arguments
- Returning values from functions
- Understanding function input and output
- Function scope
- Reloading functions at shell startup
- Scripts
- Scripting methods
- Writing a shebang script
- Finding scripts with PATH
- System bindir
- User bindir
- Arguments to scripts
- Understanding sh vs bash
- Using env
- Choosing between functions and scripts
- Using functions in scripts
- Summary
- Chapter 8: Best Practices
- Quoting correctly
- When you don't want quotes
- Handling filenames starting with dashes
- Separating output and diagnostics
- Keeping scripts brief and simple
- Keeping scripts flexible
- Respecting and applying the user's configuration
- Allowing scripts to run without user input
- Limiting the scope of shell state changes
- Avoiding path anti-patterns
- Avoiding Bash for untrusted user input
- Documenting scripts
- Writing comments
- Providing help output
- Writing manual pages
- Using temporary files cleanly
- Cleaning up after a script
- Tools to check shell scripts for problems
- Summary
- Other Books You May Enjoy
- Index.