Answers for "bash regex if condition"

2

bash conditional regex match

Just appreciate next solution example for your code implementation:
S=finding
if[[ "$S" == *ing ]]; then ...//some code run if string ends with 'ing'
More generally:
if[[ "string_to_check" == regex_patten ]]; then ...//some code
Posted by: Guest on November-03-2020
1

bash regex if condition

Use following structure:
if [[ $digit =~ [0-9] ]]; then //run if a digit included in $digit string
    echo "$digit is a digit"
else
    echo "oops"
fi
Posted by: Guest on November-03-2020

Code answers related to "Shell/Bash"

Browse Popular Code Answers by Language