Good afternoon,
I have been searching the web, and these forums for help. I will try my best to explain the issue, and what my desired results are.
I am doing queries in MYSQL, and need the output to be sent to a file. That file needs to have things with the same ID on the same line. To give you an idea, if I query the names of drinks, it may come out like this:
type,name
juice,orange
juice,apple
pop,coca cola
pop,pepsi
How would I get the output to be like this:
juice,orange,apple
pop,coca cola,pepsi
Here is some sample output from the script I am working on:
sample output:
9993 10.10.50.0/24 blockAdminName Username One
9993 10.10.50.0/24 block_name Servers
9993 10.10.50.0/24 blockAdminEmail username.one@people.com
9993 10.10.50.0/24 blockAdminPhone 312-555-1212
9993 10.10.50.0/24 blockAdminId 1234
9993 10.10.50.0/24 blockSecName Username Two
9993 10.10.50.0/24 blockSecEmail username.two@people.com
9993 10.10.50.0/24 blockSecPhone 312-555-2121
9993 10.10.50.0/24 blockSecId 7891
9993 10.10.50.0/24 blockTechName Username Three
9993 10.10.50.0/24 blockTechEmail username.three@people.com
9993 10.10.50.0/24 blockTechPhone 312-555-1313
9993 10.10.50.0/24 blockTechId 4567
9992 10.10.40.0/24 block_name unknown
9992 10.10.40.0/24 blockAdminName Username One
9992 10.10.40.0/24 blockAdminEmail username.one@people.com
9992 10.10.40.0/24 blockAdminPhone 312-555-1212
9992 10.10.40.0/24 blockAdminId 1234
9992 10.10.40.0/24 blockSecName Username Two
9992 10.10.40.0/24 blockSecEmail username.two@people.com
9992 10.10.40.0/24 blockSecPhone 312-555-2121
9992 10.10.40.0/24 blockSecId 7891
9992 10.10.40.0/24 blockTechName Username Three
9992 10.10.40.0/24 blockTechEmail username.three@people.com
9992 10.10.40.0/24 blockTechPhone 312-555-1313
9992 10.10.40.0/24 blockTechId 4567
9991 10.10.30.0/24 block_name unknown
9991 10.10.30.0/24 blockAdminName Username One
9991 10.10.30.0/24 blockAdminEmail username.one@people.com
9991 10.10.30.0/24 blockAdminPhone 312-555-1212
9991 10.10.30.0/24 blockAdminId 1234
9991 10.10.30.0/24 blockSecName Username Two
9991 10.10.30.0/24 blockSecEmail username.two@people.com
How can I get this to put everthing on three lines? Notice that there are only three different ID's (9991, 9992, 9993). Ideally, I would want something like this:
9992,10.10.50.0/24,blockAdminName="Username One",block_name="Servers",blockAdminEmail="username.one@people.com",blockAdminPhone="312-555-1212",blockAdminId="1234",blockSecName="Username Two",blockSecEmail="username.two@people.com",blockSecPhone="312-555-2121",blockSecId="7891",blockTechName="Username Three",blockTechEmail="username.three@people.com",blockTechPhone="312-555-1313",blockTechId="4567"
Notice that everything is on one line now. The first two columns are the same (9993 and 10.10.50.0/24). So it kept those and then put everything after that comma delimmited.
How can I accomplish this in Perl or Bash?
Thank you very much!!!!!