I have an input file which contains the following data...
sno: 10
id: 15000
firstname: abcd
mail: abcd@mail.com
secondname: efgh
mail: efgh@mail.com
sno: 11
id: 15001
firstname: ijkl
mail: ijkl@mail.com
secondname: mnop
mail: mnop@mail.com
sno: 12
id: 15002
firstname: qrst
mail: qrst@mail.com
secondname: uvwx
mail: uvwx@mail.com
sno: 13
id: 15003
firstname: mike
secondname: shane
mail: shane@mail.com
sno:14
id: 15004
secondname: donald
mail: donald@mail.com
sno: 15
id: 15001
firstname: abcd
mail: abcd@mail.com
secondname: efgh
mail: efgh@mail.com
sno: 16
id: 15001
firstname: ijkl
mail: ijkl@mail.com
secondname: mnop
mail: mnop@mail.com
sno: 17
id: 15002
firstname: abcd
mail: abcd@mail.com
secondname: efgh
mail: efgh@mail.com
sno: 18
id: 15003
firstname: ijkl
mail: ijkl@mail.com
secondname: mnop
mail: mnop@mail.com
sno: 19
id: 15004
firstname: abcd
mail: abcd@mail.com
secondname: efgh
mail: efgh@mail.com
sno: 20
id: 15006
firstname: ijkl
mail: ijkl@mail.com
secondname: mnop
mail: mnop@mail.com
sno: 21
id: 15004
firstname: abcd
mail: abcd@mail.com
secondname: efgh
mail: efgh@mail.com
sno: 22
id: 15004
firstname: abcd
mail: abcd@mail.com
secondname: efgh
mail: efgh@mail.com
I need an tilde seperated output file as follows....
10~15000~1~abcd~abcd@mail.
com~efgh~e
fgh@mail.c
om
11~15001~3~ijkl~ijkl@mail.
com~mnop~m
nop@mail.c
om
12~15002~2~qrst~qrst@mail.
com~uvwx~u
vwx@mail.c
om
13~15003~2~mike~ ~shane~shane@mail.com
14~15004~4~ ~ ~don~don@mail.com
20~15006~1~ijkl~ijkl@mail.
com~mnop~m
nop@mail.c
om
Please note: If there is a firstname's mail id missing, as in the case of sno: 13, it should leave a blank space as shown in the output file.
Also in sno: 14 both the firstname and firstname's mail id are missing....so it should leave a blank spaces for both as shown in the output.
I don't have the option of distinguishing the firstname's mail id and secondname's mail id.........since both of them start with xmail: so if the firstname's mail id is missing there is a chance that it takes second name's mail id in the output file.
Please try to provide me with a unix script for the above. I am using sun solaris. This is just sample data....i have data from sno: 1 to sno: 5000 in my input file. The firstname will be followed by firstname;s mail id and secondi name will be followed by secondname's maild id. Please make sure there will be no problems if there is any missing data like... firstname missing........secondname missing......secondname's mail id missing.....firstname's mail id missing......sno's missing and so on..............it should leave a blank space in the above cases.
Also i should get a count of haw many times the id is repeating as shown in the output file.for example, If the id is repeating 4 times as in the case of 15004. I should get that count and the remaining three entries can be left out. No matter what the other fileds (sno,firstname,mail,second
name,mail)
may be. It should be uniqed by the id only and i should get that count.
Please do make it as soon as you can as it is pretty urgent