Linux.com

Home Linux Community Forums New to Linux Getting Started with Linux Flow control based on grep match pattern or string

Flow control based on grep match pattern or string

Link to this post 27 Oct 13

Hi,

Looking to create a flow control based on a string or pattern matched in a log file.

The log file may contain either of these

1 CONFSUCCESS
2 CONFFAIL
3 CONFPARTIAL

Example:
cat System.log

dsfasdfasfas
adfsfasfa
safafaf sdfaasfsa CONFSUCCESS
adsfasdfadsfadsf fafasfasdfasdf fafasfafsa
sadfafasfasdfadss fdsafadff fasfadfaf asff

So idea is to grep the message from log, based on pattern run a flow control as below.

if

1 Look in System.log - CONFSUCCESS - show message as - SUCCESSFUL - Ask user to - Press ENTER to continue

if

2 Look in System.log - CONFFAIL - show message as - FAILURE - Exit (come out of shell)

if

3 Look in System.log - CONFPARTIAL - Show message as - PARTIALSUCCESS - Exit (come out of shell)

Thanks

Who we are ?

The Linux Foundation is a non-profit consortium dedicated to the growth of Linux.

More About the foundation...

Frequent Questions

Join / Linux Training / Board