shell script basic doubt

hi,
I am new script learner,
so my basic doubt is ,
how to store value of any command in a variable example

$ ls | wc -l

i want to stote the output of this in a variable c.
so that i can use c in if else loop.

and when do we use " ` " symbol in script..
can anyone also tell for learner whick ebook i should use..

to put command in variable....

var=$(ls | wc -l);echo $var

You can assign the output of a command to a variable as follow:

c=`ls | wc -l`

or

c=$(ls | wc -l)

Some useful links:

http://www.unix.com/answers-frequently-asked-questions/13774-unix-tutorials-programming-tutorials-shell-scripting-tutorials.html

HI,
Thanks for reply,
can you please help me , i am trying to write just small script, for testing, i am getting error as follows..

count(){
var=$(ls | wc -l)
}
count
echo $var
loop_test(){
if [$var -eq 3]
        then
                echo "its true"
        else
                echo "its false"
fi
}
loop_test

ERROR:

$ ./script
3
./script: line 8: [3: command not found

Give a space after "[".

if [ $var -eq 3 ]

Thanks protocomm, Franklin52, panyam

I am able to learn script with u all guys,
now my test script is running.
Thanks alot.