Seven Flashcards
Elements in a regular expression
RE is used in matching patterns
link:
http://tldp.org/LDP/abs/html/x17129.html
A character set
An anchor: these designate the position in the line of text that the RE is to match.
Modifiers: These expands or narrow the range of text of txt
sed command
sed in a nutshell is used to modify text content.
echo ${string/what/A}
This will substitute what in string by A
echo ${string:0:number}
Output 0:number length which doesn’t contain number
: ‘multiple lines here’
This is another way to write the comment here
cat > filename
output the comments to the filename
eval echo \${$var}
Usually, echo ${$var} is a syntax error, because we can only have one variable name in the curly parenthesis. eval takes the multiple strings as its input like they are typed from the command line when the $ will be translated. And then it puts them together and run them.
array initialization
array=(var1 var2 var3 var4)
what is the function of a code block
{code block} : I/O redirection
Note: redirect everything in the block
expr
expr arithmetic expression
ex. expr 3 * 2
sometimes, it has to be escaped
=~
=~ is used to match regex ex. variable="This is a fine mess" if [[ "$variable" =~ T.......fin*es* ]] then .... fi double quote for T.....fin*es* is not necessary, and it may cause error