- : enable the option
+ : disable the option
Example:
set -o errexit
equals to
set -e
Control operators:
& && ( ) \n ;; ; | ||
Redirection operators:
< > << >> <> <& >& <<- >|
Single Quotes: preserve the literal meaning of all the chars except '
Double Quotes: preserve the literal meaning of all the chars except $ ` \
Backslash: preserve the literal meaning of all the chars except \n
Reserved Words:
! { } case do done elif else esac fi for if then until while
Aliases:
Commands:
Simple Commands Order:
Leading words name=value; Word Expansions; Redirection
Redirections:
[n]> file
[n]>| file
[n]>> file
[n]< file
[n]<> file
[n]<&n2
[n1]<&-
[n1]>&n2
[n]>&-
Search and Execution:
shell functions,
built-in commands,
normal programs
Path Search for normal programs:
shell function, built-in, then PATH
Command Exit Status:
zero succeed
non-zero failure
128+signo terminated by a signal
Complex Commands:
simple command
pipeline
list or compound-list
compound command
function definition
Pipelines:
[!] command1 [| command2 ...]
Background Commands:
command1 & [command2 & ...]
Lists:
Short-Circuit List Operators:
&& ||
Flow-Control Constructs:
if list
then list
else iist
fi
while list
do list
done
for variable [in word ...]
do list
fone
break [num]
continue [num]
case word in
pattern) list ;;
...
esac
Grouping Commands Together:
(list)
or
{ list; }
Functions
name ( ) command
local variable
return [exit status]
Variables and Parameters:
name=value
Positional Parameters:
$0 $1 ...
Special Parameters:
$*: positional parameters starting from one
$@: positional parameters starting from one
$#: number of positional parameters
$?: the exit status of the most recent pipeline
$-: the current option flags
$$: the process id of the invoked shell
$!: the process ID of the most recent background command
$0: name of the shell or shell script
Word Expansions:
Tilde Expansion, Parameter Expansion, Command Substitution,
Arithmetic Expansion, Quote removal
Tilde Expansion:
~/.tools/list
/usr/name/.tool/list
Parameter Expansion:
${expression}
${parameter:-word} : Use default value
${parameter:=word} : Assign default value
${parameter:?[word]} :Indicate Error if Null or Unset
${parameter:+word} : Use Alternate Value
${#parameter} : string length
${parameter%word} : Remove smallest suffix pattern
${parameter%%word} : Remove largest suffix pattern
${parameter#word} : Remove smallest prefix pattern
${parameter##word} : Remove largest prefix pattern
Command Substitution:
$(command) or
`command`
Arithmetic Expansion:
$((expression))
While Space Splitting:
Pathname Expansion:
Shell Patterns:
! * ? [
*: any string of chars
?: any single char
[: introduce a char class
]: end a char of class
Built-in Commands:
: null cmmand that return a 0 exit value
. file: file is read and excuted
[ : built-in equivalent of test
alias [name[=string] ...] :
bg [job ...': background
builtin cmd: execute the specified built0in command
bind:
cd directory:
chdir:
command [-p]
command [-v]
echo [-e | -n] [string ...]
eval string ...
exec [command [arg ...]]
exit [exitstatus]
export name ...
export [-p]
false
fc [-e editor]
fc -l
fc -s
fg [job]
getopts optstring var
hash [-rv] [command ...]
jobid [job]
jobs [-lps]
local:
pwd [-L | -P]
read [-p prompt] [-t timeout] [-er] variable
readonly [-p] [name]
return [exitstatus]
set [-/+abCE..]
setvar variable value
shift [n]
test
times:
trap [action] signal
trap -l
true
type [name ...]
unlimit
unmask
unalias
unset
wait [job]
No comments:
Post a Comment