shell scripting Flashcards
$x
accessing a variable
‘$x’ vs. “$x”
string literal vs. variable
special characters:
” , $, `, “, *
read
reads input; by default, splits the input into words, considering <space>, <tab>, and <newline> characters as word delimiters</newline></tab></space>
read -s
suppress the printout of the input
read -p
specify prompt message
read -t N
timeout after N seconds
read -n N
read exactly N characters
:-
replace a empty variable with a default value
:=
assign default values to empty variables
-n <string></string>
length non-zero
-z <string></string>
length zero
<string>
</string>
string non-zero
-eq
is equal
-neq
not equal
-gt
greater than
-ge
greater than or even
-lt
lesser than
-le
lesser than or even
-e
exists
-f
exists and is a regular file
-d
exists and is in directory
-s
exists and its size is larger than zero
-nt
newer than
-ot
older than
continue
skips the rest in the current iteration and starts a new iteration
$0
name of the script
$1-$9
argument
$@
all arguments
$#
number of arguments
$?
return code of the previous command
$$
PID of the current command
!!
entire last command with arguments
$_
last argument of last command