formatting output

Hi need some advice..

#grep -i hostname test.csv
(gives the below output)

HOSTNAME,name,host_test,,,,,,,,

Now I need to format the above output as below.

HOSTNAME:
name=host_test

Any easy way of doing this using awk or sed or printf?

$ awk 'BEGIN{FS=","} {printf("%s:\n%s=%s\n",$1,$2,$3)}' test.csv 
HOSTNAME:
name=host_test
HOSTNAME2:
name=host2_test
HOSTNAME3:
name=host3_test

Cheers,
ZB

Thanx zazzybob !!!

well i need to extend my question.

the solution provided is fine when you know the number of field. let me expalin more

HOSTNAME,name,host_test,,,,,,,,
HOSTNAME,name,host_test2,ip_address,192.168.1.1,,,,,,,,
HOSTNAME,name,host_test3,ip_address,192.168.5.1,netmask,255,255,255,0

so i need to convert the above format in to below stanza format

HOSTNAME:
name=host_test

HOSTNAME:
name=host_test2
ip_address=182.168.1.1

HOSTNAME:
name=host_test3
ip_address=192.168.5.1
netmask=255,255,255,0

The problem over here is that different lines have different count of coma seperated values.. and i need to print them all..

can we have awk look for number of fields and print them accordingly?

Assuming netmask is 255.255.255.0 and not 255,255,255,0:

awk '{print $1":"
	for(i=2;i<=NF;i++)
		if(i%2==0)
			printf "%s=%s\n", $i,$(i+1)
		print "\n"
}' FS="," filename

Yes.. that solved my problem.. thanks a lot dude.. you people rock :b: