sort the last names

hi all

i have a datafile consists of fields seperated by colons. the fields are as follows : a) First and last name
b) Phone number
c) Address
d) Birth date
e) Salary

now i want to write a script naming lookup.sh using vi editor which consists of following operations:

a) sort the data files by last names
b) show the user the content of the datafile
c) Display the user the number of entries
in the file

...

Post your sample input file and expected output.

i have a input file naming lookup.txt and the data is :

sonu pal:9897933005:pimpri:19/05/1988:15000
vijay aggarwal:9897933006:akurdi:19/05/1987:20000
ajay singh:9897933007:dapodi:19/05/1986:25000
mahesh rana:9006752312:chinchwad:21/09/1976:50000

and the expected o/p must be like this :

vijay aggarwal:9897933006:akurdi:19/05/1987:20000
sonu pal:9897933005:pimpri:19/05/1988:15000
mahesh rana:9006752312:chinchwad:21/09/1976:50000
ajay singh:9897933007:dapodi:19/05/1986:25000

the number of entries in a line = 5
total number of entries in a file = 20

Hi, Try this,

sort -k2 inputfile ; awk -F":" 'END{print "the number of entries in a line =" NF; print "total number of entries in a file = " NF*NR}' inputfile

hi pravin27,

It is showing the output like this ...but the output of last two lines are zero which is incorrect...

vijay aggarwal:9897933006:akurdi:19/05/1987:20000
sonu pal:9897933005:pimpri:19/05/1988:15000
mahesh rana:9006752312:chinchwad:21/09/1976:50000
ajay singh:9897933007:dapodi:19/05/1986:25000
the number of entries in a line =0
total number of lines =0