shell script + match word without echo command

0

the following test syntax is part of ksh script

   [[ $PARAM = TRUE ]] &&  [[ ` echo $LINE_FROM_FILE | grep -c Validation ` -eq 1 ]] && print "find Validation word"

Can I get some other creative syntax/solution/command to verify if Validation word exists in LINE_FROM_FILE without to use the echo command?

LINE_FROM_FILE="123 Validation V125 tcp IP=1.2.56.4"

lidia

lidia

Posted 2010-08-25T10:10:56.430

Reputation: 629

Answers

0

... && [[ $LINE_FROM_FILE == *Validation* ]] && ...

Ignacio Vazquez-Abrams

Posted 2010-08-25T10:10:56.430

Reputation: 100 516

not good because if I have Validatio and not Validation its also match , did you have other solution – lidia – 2010-08-25T10:30:17.220

Are you sure that this is with ksh then? == should do glob matching, and =~ does regex matching. – Ignacio Vazquez-Abrams – 2010-08-25T10:37:34.667

try with LINE_FROM_FILE="1 2 3 ValidationWORD" its also match – lidia – 2010-08-25T10:58:02.940

But that would match with your original command as well. – Ignacio Vazquez-Abrams – 2010-08-25T12:07:04.107

0

if the word separator in the "line from file" is always one or multiple spaces, try this:

if [[ " $LINE_FROM_FILE " == *" Validation "* ]] 

do'nt forget the quotes

Gilles Pion

Posted 2010-08-25T10:10:56.430

Reputation: 21