Command to extract word from a string

Hi All,

I have a word and from that word would like to search for certain set of string, is there any command to do so ?

EX :

Components

from the above word, would like to search for strings set and extract the search string and then do if stmt...

pon
nen
ent
Com

say something like this,

search_word="Components"

result=grep Com $search_word

and in $result i want the just the extracted word ie, result=Com

Thanks,
Ops

try something like below

if [ `awk 'BEGIN { print index("Component", "Com") }'` -gt 0 ]
then
echo "Com"
fi

Totally longhand using __builtins__, CygWin bash under Windows Vista...
All done with understandable variables so you can see how it works...

#!/bin/bash
# sub_str.sh
my_string="This is a component catalogue..."
substring="a c"
substring_length=3
subscript=0
for subscript in $( seq 0 1 $(( ${#my_string} - 3 )) )
do
	if [ "${my_string:$subscript:$substring_length}" == "$substring" ]
	then
		echo "Substring ~$substring~ found in ~$my_string~ at position $(( $subscript + 1 ))..."
	fi
done
exit 0

result for string "a c"...

AMIGA:~> cd /tmp
AMIGA:/tmp> dos2unix sub_str.sh
dos2unix: converting file sub_str.sh to Unix format ...
AMIGA:/tmp> ./sub_str.sh
Substring ~a c~ found in ~This is a component catalogue...~ at position 9...
AMIGA:/tmp> _