Dec 18, 2007 #1 bdw238 MIS Dec 15, 2005 52 GB Hello, Can someone advise me how to pattern match like the following bit of perl code in BASH $message="There has been an error detected"; $pattern="error"; if ($message =~ m/$pattern/i) { print "Found error\n"; } elsif { # Do nothing } Brian
Hello, Can someone advise me how to pattern match like the following bit of perl code in BASH $message="There has been an error detected"; $pattern="error"; if ($message =~ m/$pattern/i) { print "Found error\n"; } elsif { # Do nothing } Brian
Dec 18, 2007 #2 hoinz MIS Jan 29, 2004 944 DE for a start: man grep man bash e.g. your example: message="There has been an error detected" pattern="error" echo $message | grep -q $pattern && echo "Found error" hope this helps Upvote 0 Downvote
for a start: man grep man bash e.g. your example: message="There has been an error detected" pattern="error" echo $message | grep -q $pattern && echo "Found error" hope this helps
Dec 18, 2007 #3 PHV MIS Nov 8, 2002 53,708 FR case $message in *$pattern*) print "Found error\n";; esac Hope This Helps, PH. FAQ219-2884 FAQ181-2886 Upvote 0 Downvote
case $message in *$pattern*) print "Found error\n";; esac Hope This Helps, PH. FAQ219-2884 FAQ181-2886
Dec 18, 2007 #4 Annihilannic MIS Jun 22, 2000 6,317 AU Or: [tt]if [[ $message = *$pattern* ]] ; then echo "Found error" ; fi[/tt] Annihilannic. Upvote 0 Downvote