Need help with substring

I need to check the occurrence of one string within another.

code
********************
if [ 'some_string' = "$LINE" ];then do something done
********************

Thanks

I tried doing this but it is not working
Code
**********************************
#!/bin/ksh
s1="string"
if [ `awk -v a="$s1" -v b="ing" 'BEGIN{print index(a,b)}'` -ne 0 ] ;then echo "success"
else echo "not"
fi
**********************************
At command line the error is
" bailing out near line"

Thanks

awk -v a="$s1" -v b="ing" 'BEGIN{print match(a,b)}'

i tried the match function.the error message that i get is

test.sh: errorfile: not found. I made the following change
code
*****************
#!/bin/ksh
s1="string"
if [ ` awk ="$s1" -v b="ing" 'BEGIN{print match(a,b)}'` -ne 0 ] ;then echo "success"
else echo "not"
fi
********************

Not sure if this is the right way to run awk in side if statement.

Thanks

This is not what I've posted.

Apologize for the incorrect paste. I am actually trying various versions to see how that works.

Here was the code that was used

code

******************

s1="string"
if [ `awk -v a="$s1" -v b="ing" 'BEGIN{print match(a,b)}'` -ne 0 ] ;then echo "success"
else echo "not"
fi
*********************

The error is

test.sh: errorfile: not found

Am I using the awk correctly inside the if statement.

Thanks

Firstly, please use BB Codes when posting code/data sample in the future.

Secondly, I don't see in your sample code any reference to 'errorfile' file. Are you sure this is a complete and accurate representation of you code sample?

Thirdly, if you're on Sun/Solaris, use 'nawk' instead of 'awk'.

Here's my code:

#!/bin/ksh
s1="string"
if [ `nawk -v a="$s1" -v b="ing" 'BEGIN{print match(a,b)}'` -ne 0 ] ;then echo "
success"
else echo "not"
fi

The output of this script is 'success'.

Thanks V for looking into this. I am on SunOS and the nawk works the way you listed. I will follow the bb codes in future.

Thanks Again