Five:SPECIAL CHARACTERS Flashcards
semicolon ;
A semicolon allows to write multiple lines of command in one line.
Note: there is a space after ever semicolon
double semicolon ;;
The double semicolon is used in the case switch expression
The case expression
case $variable in var1) statement ;; var2) statement ;; *) statement ;; esac
dot .
as a component of a filename
also file is hidden if it is prefixed by a dot
dot . in character match
match only one character
double quote
preserve most of the special chracter
comma operator
all evaluated, but only the last one returned
comma in concatenation
/usr/{,share/}bin
represents
/usr/bin
/usr/share/bin
command colon
”:” is itself a bash built-in and may be equivalent to true
:»_space; filename This combination do nothing to an existing file but create it if it does not exist
: > filename This empty a file
colon as a field separator
PATH=PATH1:PATH2
a double parenthesis
((condition ? state1 : state2))
${parameter?err_msg}, ${parameter:?err_msg}
if parameter is set, use it, else print err_msg
? serves as a single wild card
?name
listing arguments
”$@” and “$*” note that these two should be quoted
$?
exit status
(command group)
The variables in the parenthesis is local inside the parenthesis
cat {file1,file2,file3} > filename
no space is allowed in the bracket
this combine these three files to just one file
cp file{extension1,extension2}
this copies two files with the different extension
block of code
{command block} the content in the block can be seen by the remain of the script unlike the condition in the parenthesis {read line1 read line2 }
equivalence of test
[]
[
test
[[]]
difference between [] and [[]]. The [] doesn’t evaluate
[[]] evaluates
There must be a space between the [ and the chactaters
if you want to use && and || operator, best use [[ ]]
if command expression
if takes the exit value from the command expression
(()) and $[]
evaluate integer expansion
cd -
get into the previous working directory
previous working directory
~-