Formatting output

Hi,
I am new to shell scripting, I ahve written a shell script which would extract me data, but my problem is I want to add a column name to my output. Using grep and sed I am getting my data from the input file.

Sample data
name : eric
name : tom
name : sean

My output using grep and sed is :
eric
tom
sean
But I want my output as
name
eric
tom
sean
I tried searching as much as possible in google and in the forum, but no luck. If it is a repeated question, I am extremely sorry. If someone can help me out in this regard, that would be great. I tried using
awk '/name/ {print $2}' test.tmp , but this gives me only eric, tom,etcc..but name is not getting displayed.

Your valuable help is really appreciated.

Thanks in Advance
Sandeep

Try this code :
i=1
cat $my_input_file | while read line
do
if [ $i -eq 1 ]
then
echo $line | cut -d':' -f1 > $my_output_file
fi
echo $line | cut -d':' -f2 >> $my_output_file
i=$(($i+1))
done
cat $my_output_file

Rgds.

UUoC

while read line; do
...
done < $my_input_file

Cheers
ZB

Hi,

Thanks very much for your replies, but I ahve come out with another work around. I am using a function like this
*********************************
function extract
{
echo $1
grep "$1" /home/sjagadee/$2 | sed "s/$1//g"| sed "s///g"
}
*
******************************
where in $1 would be my search criteria, $2 my filename.

Thanks a ton
Sandy