Return value

Hallo

I want write a sh script but I have some troubles!

How can I write the Return value to a variable? I need an egrep command with the option -c, how many times it give the pattern. This return value shold be written in a variable.

Could you help me?

Read the man page on sh, ksh. There is a lot of information in there.

x=`grep -c pattern /tmp/myfile`
echo $x