Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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

share|improve this question
add comment

2 Answers 2

up vote 0 down vote accepted
... && [[ $LINE_FROM_FILE == *Validation* ]] && ...
share|improve this answer
    
not good because if I have Validatio and not Validation its also match , did you have other solution –  lidia Aug 25 '10 at 10:30
    
Are you sure that this is with ksh then? == should do glob matching, and =~ does regex matching. –  Ignacio Vazquez-Abrams Aug 25 '10 at 10:37
    
try with LINE_FROM_FILE="1 2 3 ValidationWORD" its also match –  lidia Aug 25 '10 at 10:58
    
But that would match with your original command as well. –  Ignacio Vazquez-Abrams Aug 25 '10 at 12:07
add comment

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

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.