Although I am almost sure this has been covered, I can\'t seem to find anything specific to this. As I continue my journey on learning bash I keep finding parts where I am b
I made this simple function:
match() {
TRUE=1
FALSE=0
match_return=0
echo $1 | grep $2 >/dev/null
[ $? -eq 0 ] && match_return=$TRUE || match_return=$FALSE
}
Usage:
match Testing Test ; [ $match_return -eq 1 ] && echo "match!" || echo "nope"
entire code: https://gist.github.com/TeeBSD/5121b3711fad40a09455