File formatting with awk

Thread Tools Search this Thread
# 1  
Old 12-29-2017
File formatting with awk

Hi, I would like to format the file input example to the specific output example. I have tried numerous different ways, however not able to extract the information as desired. Any assistance to get the file formatted would be truly appreciated:
server:<server url="" lat="43.6000" lon="-79.6500" name="Mississauga, ON" country="Canada" cc="CA" sponsor="Rogers" id="8783"  url2="" host="" />
server:<server url="" lat="43.5658" lon="-80.9222" name="Milverton, ON" country="Canada" cc="CA" sponsor="Mornington Communications Ltd" id="10727"  url2="" host="" />
server:<server url="" lat="43.5625" lon="-81.6980" name="Bayfield, ON" country="Canada" cc="CA" sponsor="Tuckersmith Communications" id="3533"  url2="" host="" />

Code:;43.6000;-79.6500;Mississauga, ON;Canada;CA;Rogers,8783;;;43.5658;-80.9222;Milverton, ON;Canada;CA,Mornington Communications Ltd;10727;;;43.5625;-81.6980;Bayfield, ON;Canada;CA;Tuckersmith Communications;3533;;

Attempts to format:
awk 'BEGIN{FS="=";OFS=","}{print}' | sed 's/[{}"]//g'

# 2  
Old 12-29-2017
As has been suggested before, when posting in this forum please tell us what operating system and shell you're using.

And, instead of just showing us a three line sample input file and a three line sample output file, please also describe the logic that governs the changes you are trying to make.

The code you're using is going to a lot of effort to remove braces from the output, but since there aren't any braces in your sample input; it isn't clear why you are doing that.

The code you're using sets the output field separator to a comma, but your sample output seems to use semicolon as a field separator.

Please clearly explain what you are trying to do and be sure that the sample output you have provided really matches the output you hope to produce from that input.
# 3  
Old 12-30-2017
Apologies for not being clear. The idea is to have the file formatted in a semicolon way, without the description in front. If you look at the raw file it describes everything with e.g. url= which I would like to remove and the quotation marks around the info. So the idea is to have a well formatted file output with only the information, also most like a CSV using the e.g. url as header instead of in the body itself.
# 4  
Old 12-30-2017
And Don Cragun's other questions?

Thread Tools Search this Thread
Search this Thread:
Advanced Search

More UNIX and Linux Forum Topics You Might Find Helpful
Suffix formatting with awk expert Shell Programming and Scripting 7 11-07-2013 04:59 AM
Data formatting using awk ajayram_arya Shell Programming and Scripting 4 08-13-2013 04:25 PM
Help with awk'ing formatting this newbie_01 UNIX for Dummies Questions & Answers 2 06-23-2013 03:03 AM
AWK/Shell script for formatting data in a file rajivnairfis Shell Programming and Scripting 1 05-14-2012 08:57 AM
awk formatting messi777 UNIX for Dummies Questions & Answers 7 04-03-2012 06:28 AM
formatting awk rocking77 Shell Programming and Scripting 5 06-17-2011 01:23 PM
AWK printing formatting help please newbie_01 Shell Programming and Scripting 2 04-30-2011 09:41 AM
AWK formatting help. Peasant Shell Programming and Scripting 5 04-22-2011 12:43 PM
output formatting with awk. pinga123 Shell Programming and Scripting 2 11-26-2010 07:55 AM
formatting data file with awk or sed lego Shell Programming and Scripting 5 03-26-2010 11:11 PM
Help with txt formatting using AWK eknryan Shell Programming and Scripting 13 08-11-2009 05:56 AM
awk script formatting King Nothing Shell Programming and Scripting 10 11-26-2008 03:28 AM
Formatting file with Awk? SAMZ UNIX for Advanced & Expert Users 6 08-13-2008 12:27 PM
Awk formatting of a data file - nested for loops? catwoman Shell Programming and Scripting 3 07-04-2008 03:27 AM
Formatting using awk cdunavent Shell Programming and Scripting 2 03-18-2003 02:09 PM