Bash Pocket Reference: Help for Power Users and Sys Admins

Bash Pocket Reference: Help for Power Users and Sys Admins

Language: English

Pages: 156

ISBN: 1491941596

Format: PDF / Kindle (mobi) / ePub


It’s simple: if you want to interact deeply with Mac OS X, Linux, and other Unix-like systems, you need to know how to work with the Bash shell. This concise little book puts all of the essential information about Bash right at your fingertips.

You’ll quickly find answers to the annoying questions that generally come up when you’re writing shell scripts: What characters do you need to quote? How do you get variable substitution to do exactly what you want? How do you use arrays? Updated for Bash version 4.4, this book has the answers to these and other problems in a format that makes browsing quick and easy.

Topics include:

  • Invoking the shell
  • Syntax
  • Functions and variables
  • Arithmetic expressions
  • Command history
  • Programmable completion
  • Job control
  • Shell options
  • Command execution
  • Coprocesses
  • Restricted shells
  • Built-in commands

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

facilities such as +(…). Enabled automatically in POSIX mode. (These were not in the original Bourne shell; thus Bash requires you to enable them if you want them.) extquote †Allow $'…' and $"…" within ${variable} expansions inside double quotes. failglobCause patterns that do not match filenames to produce an error. force_fignore †When doing completion, ignore words matching the list of suffixes in FIGNORE, even if such words are the only possible completions. globasciirangesExpand ranges

file named on the command line and use it as the new filename: for file do name=$(sed -n 's/NAME: //p' $file) mv $file $name done for Start an arithmetic loop. for ((init; cond; incr)) do commands done Arithmetic for loop, similar to C’s. Evaluate init. While cond is true, execute the body of the loop. Evaluate incr before retesting cond. Any one of the expressions may be omitted; a missing cond is treated as being true. ExampleSearch for a phrase in each odd chapter: for ((x=1; x <= 20; x

shell variables from being assigned new values. An initial value may be supplied using the assignment syntax, but that value may not be changed subsequently. Read-only variables may not be unset. Options-aEach variable must refer to an indexed array. -AEach variable must refer to an associative array. -fEach variable must refer to a function. -pPrint readonly before printing the names and values of read-only variables. This allows saving a list of read-only variables for rereading later.

is true (used for grouping). For test and [ ], the parentheses should be quoted by a \. The [[ ]] form doesn’t require quoting the parentheses. ! conditionTrue if condition is false. condition1 -a condition2True if both conditions are true. condition1 && condition2True if both conditions are true. Short-circuit form. (Use only within [[ ]].) condition1 -o condition2True if either condition is true. condition1 || condition2True if either condition is true. Short-circuit form. (Use only within

Shell VariablesCOMP_TYPE shell variable, Built-In Shell VariablesCOMP_WORDBREAKS shell variable, Built-In Shell VariablesCOMP_WORDS shell variable, Built-In Shell Variablesconditions, evaluating, Built-In Commandscontinue command, Built-In Commandscontrol characters, filename metacharacter, Filename MetacharactersCOPROC shell variable, Built-In Shell Variablescoprocesses, CoprocessesCPU times, Built-In Commandscsh (Berkeley C shell), history, HistoryCTRL-Z job control command, Job Control, Job

Download sample

Download