Bash notes

From Reboil


These are my notes for using Bash.

Stats

Regular expressions

The =~ operator may be used to test a regular expression. Below is an example testing whether a string is an integer; note the lack of quotes or parentheses around $re (the variable storing the regular expression) inside the [[ ]].

myVar="123";
re='^[0-9]+$';
if [[ "$myVar" =~ $re ]]; then
  printf "%d is an integer." "$myVar";
else
  printf "%d is not an integer." "$myVar";
fi;

Manual

Parameters

Shell Variables

FUNCNAME
An array variable containing the names of all shell functions in the execution call stack.

History

See also


External links

References


Footnotes


Comments