<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: AWK - FS and output in Operating System - Linux</title>
    <link>https://community.hpe.com/t5/operating-system-linux/awk-fs-and-output/m-p/4966011#M101577</link>
    <description>referencecode firstname                      lastname                       group           homephone    emailaddress                                       institution &lt;BR /&gt;Sandman, &lt;BR /&gt;&lt;BR /&gt;that is about the best I can do, it contains private info.</description>
    <pubDate>Thu, 09 Mar 2006 13:54:36 GMT</pubDate>
    <dc:creator>rmueller58</dc:creator>
    <dc:date>2006-03-09T13:54:36Z</dc:date>
    <item>
      <title>AWK - FS and output</title>
      <link>https://community.hpe.com/t5/operating-system-linux/awk-fs-and-output/m-p/4966000#M101566</link>
      <description>I have a tabbed delimited flat file, I want to change it to CSV file, &lt;BR /&gt;&lt;BR /&gt;it has 7 fields. &lt;BR /&gt;&lt;BR /&gt;Any thoughts on how I can redefine output? &lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 09 Mar 2006 12:28:01 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/awk-fs-and-output/m-p/4966000#M101566</guid>
      <dc:creator>rmueller58</dc:creator>
      <dc:date>2006-03-09T12:28:01Z</dc:date>
    </item>
    <item>
      <title>Re: AWK - FS and output</title>
      <link>https://community.hpe.com/t5/operating-system-linux/awk-fs-and-output/m-p/4966001#M101567</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;try &lt;BR /&gt;awk -FS: '{gsub("\t",",");print $0}' filename&lt;BR /&gt;&lt;BR /&gt;greetings,&lt;BR /&gt;&lt;BR /&gt;Michael&lt;BR /&gt;</description>
      <pubDate>Thu, 09 Mar 2006 12:35:04 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/awk-fs-and-output/m-p/4966001#M101567</guid>
      <dc:creator>Michael Schulte zur Sur</dc:creator>
      <dc:date>2006-03-09T12:35:04Z</dc:date>
    </item>
    <item>
      <title>Re: AWK - FS and output</title>
      <link>https://community.hpe.com/t5/operating-system-linux/awk-fs-and-output/m-p/4966002#M101568</link>
      <description>This is slighty tricky in that string fields in CSV files must be surrounded by double quotes (in case the strings contain commas). This is a very easy awk or Perl task but it does requires a little customization if string data are in the file.</description>
      <pubDate>Thu, 09 Mar 2006 12:40:01 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/awk-fs-and-output/m-p/4966002#M101568</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2006-03-09T12:40:01Z</dc:date>
    </item>
    <item>
      <title>Re: AWK - FS and output</title>
      <link>https://community.hpe.com/t5/operating-system-linux/awk-fs-and-output/m-p/4966003#M101569</link>
      <description>You can use tr for that...&lt;BR /&gt;&lt;BR /&gt;# tr "\t" "," &lt;INFILE&gt;outfile&lt;BR /&gt;&lt;BR /&gt;cheers!&lt;/INFILE&gt;</description>
      <pubDate>Thu, 09 Mar 2006 12:41:43 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/awk-fs-and-output/m-p/4966003#M101569</guid>
      <dc:creator>Sandman!</dc:creator>
      <dc:date>2006-03-09T12:41:43Z</dc:date>
    </item>
    <item>
      <title>Re: AWK - FS and output</title>
      <link>https://community.hpe.com/t5/operating-system-linux/awk-fs-and-output/m-p/4966004#M101570</link>
      <description>I've tried all three suggestions, I am thinking the format of the file is problematic.. &lt;BR /&gt;&lt;BR /&gt;If I do: &lt;BR /&gt;&lt;BR /&gt;awk '{print $1"'"$2","....}' infile &amp;gt; outfile &lt;BR /&gt;&lt;BR /&gt;the fields separate on white space with commas, But if it try to tag the "tab" with FS or F the original file is retained in the output file. &lt;BR /&gt;&lt;BR /&gt;I think it is something specific with the field splitting. &lt;BR /&gt;&lt;BR /&gt;I've tried "" ' ' no quotes, around the "\t" &lt;BR /&gt;any other ideals?</description>
      <pubDate>Thu, 09 Mar 2006 12:47:40 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/awk-fs-and-output/m-p/4966004#M101570</guid>
      <dc:creator>rmueller58</dc:creator>
      <dc:date>2006-03-09T12:47:40Z</dc:date>
    </item>
    <item>
      <title>Re: AWK - FS and output</title>
      <link>https://community.hpe.com/t5/operating-system-linux/awk-fs-and-output/m-p/4966005#M101571</link>
      <description>Oh, and the other "gotcha" for CSV files, is that not only must string fields be surrounded by "'s but "'s within string fields must be escapped with an additional ". It's more than simply a trivial tr or sed task.</description>
      <pubDate>Thu, 09 Mar 2006 12:48:56 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/awk-fs-and-output/m-p/4966005#M101571</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2006-03-09T12:48:56Z</dc:date>
    </item>
    <item>
      <title>Re: AWK - FS and output</title>
      <link>https://community.hpe.com/t5/operating-system-linux/awk-fs-and-output/m-p/4966006#M101572</link>
      <description>Clay I need to escape the Commas as well?</description>
      <pubDate>Thu, 09 Mar 2006 12:50:31 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/awk-fs-and-output/m-p/4966006#M101572</guid>
      <dc:creator>rmueller58</dc:creator>
      <dc:date>2006-03-09T12:50:31Z</dc:date>
    </item>
    <item>
      <title>Re: AWK - FS and output</title>
      <link>https://community.hpe.com/t5/operating-system-linux/awk-fs-and-output/m-p/4966007#M101573</link>
      <description>Hmm,&lt;BR /&gt;&lt;BR /&gt;Why not simply use tr to replace tab's by comma's?&lt;BR /&gt;&lt;BR /&gt;Do you need to worry about commas in the tab seperated fields, within quoted strings perhaps?&lt;BR /&gt;Similarly, can there be tabs in (quoted) fields in the input file?&lt;BR /&gt;&lt;BR /&gt;Simple sample solution:&lt;BR /&gt;&lt;BR /&gt;/mnt/root # cat &amp;gt; x&lt;BR /&gt;a b     c d     e&lt;BR /&gt;/mnt/root # od -b x&lt;BR /&gt;0000000  141 040 142 011 143 040 144 011 145 012                         &lt;BR /&gt;0000012&lt;BR /&gt;&lt;BR /&gt;Using FS (I is silent :-) and OFS:&lt;BR /&gt;&lt;BR /&gt;/mnt/root # awk 'BEGIN{FS="\011"; OFS=","}{print $1,$2,$3,$4,$5,$6,$7}' x&lt;BR /&gt;a b,c d,e,,,,&lt;BR /&gt;&lt;BR /&gt;Using simple gobal substitute:&lt;BR /&gt;/mnt/root # awk '{gsub(/\011/,",",$0); print}' x&lt;BR /&gt;a b,c d,e&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;hth,&lt;BR /&gt;Hein.&lt;BR /&gt;</description>
      <pubDate>Thu, 09 Mar 2006 12:51:03 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/awk-fs-and-output/m-p/4966007#M101573</guid>
      <dc:creator>Hein van den Heuvel</dc:creator>
      <dc:date>2006-03-09T12:51:03Z</dc:date>
    </item>
    <item>
      <title>Re: AWK - FS and output</title>
      <link>https://community.hpe.com/t5/operating-system-linux/awk-fs-and-output/m-p/4966008#M101574</link>
      <description>Based on Clay's post, if commas are embedded inside the fields, which are separated by &lt;TAB&gt; characters themselves, then each of the fields should be punctuated by double-quotes.&lt;BR /&gt;&lt;BR /&gt;Here's an awk construct that would help...&lt;BR /&gt;&lt;BR /&gt;# awk -F"\t" '{OFS=",";print c$1c,c$2c,c$3c,c$4c,c$5c,c$6c,c$7c}' c='"' inp &amp;gt;out&lt;BR /&gt;&lt;BR /&gt;cheers!&lt;/TAB&gt;</description>
      <pubDate>Thu, 09 Mar 2006 12:53:07 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/awk-fs-and-output/m-p/4966008#M101574</guid>
      <dc:creator>Sandman!</dc:creator>
      <dc:date>2006-03-09T12:53:07Z</dc:date>
    </item>
    <item>
      <title>Re: AWK - FS and output</title>
      <link>https://community.hpe.com/t5/operating-system-linux/awk-fs-and-output/m-p/4966009#M101575</link>
      <description>In your case, printf in awk will be your friend. The idea is that you use -F &lt;TAB&gt; as your input field separator and the printf will include comma's in the format string. Without knowing you data format, I can't be more specific because as I have tried to explain, CSV strings require additional work --- if you are build a true CSV file.&lt;/TAB&gt;</description>
      <pubDate>Thu, 09 Mar 2006 12:53:08 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/awk-fs-and-output/m-p/4966009#M101575</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2006-03-09T12:53:08Z</dc:date>
    </item>
    <item>
      <title>Re: AWK - FS and output</title>
      <link>https://community.hpe.com/t5/operating-system-linux/awk-fs-and-output/m-p/4966010#M101576</link>
      <description>Hi Rex,&lt;BR /&gt;&lt;BR /&gt;Could you post a sample of your tab delimited file since that would help in deciphering all the special or invisble characters that need to be accounted for or escaped.&lt;BR /&gt;&lt;BR /&gt;cheers!</description>
      <pubDate>Thu, 09 Mar 2006 12:56:06 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/awk-fs-and-output/m-p/4966010#M101576</guid>
      <dc:creator>Sandman!</dc:creator>
      <dc:date>2006-03-09T12:56:06Z</dc:date>
    </item>
    <item>
      <title>Re: AWK - FS and output</title>
      <link>https://community.hpe.com/t5/operating-system-linux/awk-fs-and-output/m-p/4966011#M101577</link>
      <description>referencecode firstname                      lastname                       group           homephone    emailaddress                                       institution &lt;BR /&gt;Sandman, &lt;BR /&gt;&lt;BR /&gt;that is about the best I can do, it contains private info.</description>
      <pubDate>Thu, 09 Mar 2006 13:54:36 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/awk-fs-and-output/m-p/4966011#M101577</guid>
      <dc:creator>rmueller58</dc:creator>
      <dc:date>2006-03-09T13:54:36Z</dc:date>
    </item>
    <item>
      <title>Re: AWK - FS and output</title>
      <link>https://community.hpe.com/t5/operating-system-linux/awk-fs-and-output/m-p/4966012#M101578</link>
      <description>Data Entry People drive me nuts, &lt;BR /&gt;&lt;BR /&gt;In the First Name field there are a bunch with FN MI, so I would have to substr off the middle initial as well. I don't think the person that build the SQL output realized that.. I am going to take it back to her and have her work it from the Informix side.</description>
      <pubDate>Thu, 09 Mar 2006 13:58:04 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/awk-fs-and-output/m-p/4966012#M101578</guid>
      <dc:creator>rmueller58</dc:creator>
      <dc:date>2006-03-09T13:58:04Z</dc:date>
    </item>
    <item>
      <title>Re: AWK - FS and output</title>
      <link>https://community.hpe.com/t5/operating-system-linux/awk-fs-and-output/m-p/4966013#M101579</link>
      <description>Hi Rex:&lt;BR /&gt;&lt;BR /&gt;This may accomodate your requirements:&lt;BR /&gt;&lt;BR /&gt;# perl -pe 's/(.+?)\t+/"$1",/g;s/,([^"]+?)$/,"$1"/' filename&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Thu, 09 Mar 2006 14:03:24 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/awk-fs-and-output/m-p/4966013#M101579</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2006-03-09T14:03:24Z</dc:date>
    </item>
    <item>
      <title>Re: AWK - FS and output</title>
      <link>https://community.hpe.com/t5/operating-system-linux/awk-fs-and-output/m-p/4966014#M101580</link>
      <description>Thanks James, Clay, Sandman and all. &lt;BR /&gt;&lt;BR /&gt;I am going take a step back before I chase the damn goose around the barnyard. &lt;BR /&gt;&lt;BR /&gt;This file she gave acts as if the entire row is one field unless I break it down from the Whitespace.. (which maybe what I wind up doing.. I appreciate the help.. &lt;BR /&gt;&lt;BR /&gt;I am going to get the informix syntax book out and work with the person on formatting the output file from Informix instead.</description>
      <pubDate>Thu, 09 Mar 2006 14:09:15 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/awk-fs-and-output/m-p/4966014#M101580</guid>
      <dc:creator>rmueller58</dc:creator>
      <dc:date>2006-03-09T14:09:15Z</dc:date>
    </item>
    <item>
      <title>Re: AWK - FS and output</title>
      <link>https://community.hpe.com/t5/operating-system-linux/awk-fs-and-output/m-p/4966015#M101581</link>
      <description>Sandman, &lt;BR /&gt;&lt;BR /&gt;this is the output from your first AWK statement&lt;BR /&gt;awk -F"\t" '{OFS=",";print c$1c,c$2c,c$3c,c$4c,c$5c,c$6c,c$7c}' c='"' Conn*csv &amp;gt; rex.con&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;"","","","","","",""&lt;BR /&gt;"referencecode firstname                      lastname                       group           homephone    emailaddress                                       institution ","","","&lt;BR /&gt;","","",""&lt;BR /&gt;"&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 09 Mar 2006 14:14:28 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/awk-fs-and-output/m-p/4966015#M101581</guid>
      <dc:creator>rmueller58</dc:creator>
      <dc:date>2006-03-09T14:14:28Z</dc:date>
    </item>
    <item>
      <title>Re: AWK - FS and output</title>
      <link>https://community.hpe.com/t5/operating-system-linux/awk-fs-and-output/m-p/4966016#M101582</link>
      <description>Taking  a different tact.. Going to deal with the original file from Informix.</description>
      <pubDate>Thu, 09 Mar 2006 14:23:01 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/awk-fs-and-output/m-p/4966016#M101582</guid>
      <dc:creator>rmueller58</dc:creator>
      <dc:date>2006-03-09T14:23:01Z</dc:date>
    </item>
    <item>
      <title>Re: AWK - FS and output</title>
      <link>https://community.hpe.com/t5/operating-system-linux/awk-fs-and-output/m-p/4966017#M101583</link>
      <description>&lt;BR /&gt;Okay, these all all string fields so to produce a CSV file w/o headings then create an awk file, my.awk, like this:&lt;BR /&gt;&lt;BR /&gt;function do_csv_string(x)&lt;BR /&gt;{&lt;BR /&gt;  gsub("\"","\"\"",x)&lt;BR /&gt;  return "\"" x "\""&lt;BR /&gt;} &lt;BR /&gt;&lt;BR /&gt;{&lt;BR /&gt;  printf("%s,%s,%s,%s,%s,%s,%s\n",&lt;BR /&gt;         do_csv_string($1),do_csv_string($2),&lt;BR /&gt;         do_csv_string($3),do_csv_string($4),&lt;BR /&gt;         do_csv_string($5),do_csv_string($6),&lt;BR /&gt;         do_csv_string($7))&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;Invoke as awk -F '&lt;TAB&gt;' -f my.awk &amp;lt; infile &amp;gt; outfile&lt;BR /&gt;&lt;BR /&gt;This will correctly enclose each string in double quotes are required by CSV format and , in addition, will escape each quote within a string with an additional quote.&lt;BR /&gt;&lt;/TAB&gt;</description>
      <pubDate>Thu, 09 Mar 2006 14:23:41 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/awk-fs-and-output/m-p/4966017#M101583</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2006-03-09T14:23:41Z</dc:date>
    </item>
    <item>
      <title>Re: AWK - FS and output</title>
      <link>https://community.hpe.com/t5/operating-system-linux/awk-fs-and-output/m-p/4966018#M101584</link>
      <description>Clay, it is putting the "," at the end of each record and not splitting the fields. &lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 09 Mar 2006 14:26:16 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/awk-fs-and-output/m-p/4966018#M101584</guid>
      <dc:creator>rmueller58</dc:creator>
      <dc:date>2006-03-09T14:26:16Z</dc:date>
    </item>
    <item>
      <title>Re: AWK - FS and output</title>
      <link>https://community.hpe.com/t5/operating-system-linux/awk-fs-and-output/m-p/4966019#M101585</link>
      <description>You have incorrectly captured the &lt;TAB&gt; character as the FS. &lt;BR /&gt;&lt;BR /&gt;awk -F "\t" -f my.awk &amp;lt; infile &amp;gt; outfile&lt;BR /&gt;&lt;BR /&gt;&lt;/TAB&gt;</description>
      <pubDate>Thu, 09 Mar 2006 14:30:46 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/awk-fs-and-output/m-p/4966019#M101585</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2006-03-09T14:30:46Z</dc:date>
    </item>
  </channel>
</rss>

