Simple Bash Regex Example

since versions 3 bash has included a simple regular expression operation =~

below is a simple example of it in action

1
2
3
4
5
6
7
8
9
######### example code #########
#search for a process and print specific section
ps=`ps aux | grep stuff | awk '{print $12 "_" $13}' `

#do some stuff
if [[ $ps =~ "something im looking for" ]]; then
    #do what you want
fi
##############################