Article 59ENP [SOLVED] What does '!' exclamation mark mean in the bash conditional statement?

[SOLVED] What does '!' exclamation mark mean in the bash conditional statement?

by
pinqvin
from LinuxQuestions.org on (#59ENP)
Hi there. New to bash scripting... I know that '!' exclamation mark is widely used in string operations and as a negation in other programming languages. But what does it mean in this function? Can you please explain what the conditional is supposed to do exactly?

Code:#!/bin/bash

# Fancy colorful echo messages

function echo_message(){
local color=$1;
local message=$2;
if ! [[ $color =~ '^[0-9]$' ]]; then
case $(echo -e $color | tr '[:upper:]' '[:lower:]') in
# black
header) color=0 ;;
# red
error) color=1 ;;
# green
success) color=2 ;;
# yellow
welcome) color=3 ;;
# blue
title) color=4 ;;
# purple
info) color=5 ;;
# cyan
question) color=6 ;;
# orange
warning) color=202 ;;
# white
*) color=7 ;;
esac
fi
tput bold;
tput setaf $color;
echo '-- '$message;
tput sgr0;
}Thank you!

Rustamlatest?d=yIl2AUoC8zA latest?i=SriILSk76Wk:l6vMba3hI5g:F7zBnMy latest?i=SriILSk76Wk:l6vMba3hI5g:V_sGLiP latest?d=qj6IDK7rITs latest?i=SriILSk76Wk:l6vMba3hI5g:gIN9vFwSriILSk76Wk
External Content
Source RSS or Atom Feed
Feed Location https://feeds.feedburner.com/linuxquestions/latest
Feed Title LinuxQuestions.org
Feed Link https://www.linuxquestions.org/questions/
Reply 0 comments