Unix Shell Novice - File Manipulation

Hi,

I am brand new to unix and am hoping someone can start me in the right direction.
I want to be able to put the results of a file command such as wc -l filename into a variable which I can then use to test against another variable...i.e. I need to show the nth line of a file, but need to determine if the file contains at least n lines. currently the output from wc -l filename gives me a return of n filename - all I want is n as a numerical value.

Secondly, is there a way to retrieve the nth line of a file using a single command (similar to head or tail, but actually giving the line number?)

If anyone can help it would be appreciated.

Suppose you want to check a file if it contains 15 or more lines and print the 12th line:

#! /bin/ksh

a=`wc -l filename | awk '{print $1}'`
if [[ $a -gt 15 ]]; then
sed -n '13q;12p' filename
fi

EDIT---
One other way can be:
You want to print nth line of a file

n=11
head +"$n" filename | tail -1

Yet another way :

n=11
awk "NR==$n {print;exit}" filename

Jean-Pierre.

n=11
sed -n "$n p" filename

For shell programming look at Advanced Bash-Scripting Guide