Answers for "bash match regex in if"

1

bash regex match

if [[ "test" =~ ^(.*)(\.[a-z]{1,5})$ ]]; 
then 
  echo "matched"; 
else 
  echo "Not matched"; 
fi
Posted by: Guest on February-04-2022
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