<?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: Reformatting Text with AWK. in Operating System - Linux</title>
    <link>https://community.hpe.com/t5/operating-system-linux/reformatting-text-with-awk/m-p/5090610#M93284</link>
    <description>Try the awk construct below. It uses a comma as the field delimiter and the output can still be CSV as long as the OFS (output field separator) variable which is internal to awk(1) is set to a comma i.e.&lt;BR /&gt;&lt;BR /&gt;# cat file&lt;BR /&gt;"Whitman, Slim J",slim@HOTMAIL.COM,Public Schools,01/17/2008,60,&lt;BR /&gt;&lt;BR /&gt;# awk -F, '{OFS=",";print $3,$4,$5,$6}' file&lt;BR /&gt;slim@HOTMAIL.COM,Public Schools,01/17/2008,60&lt;BR /&gt;&lt;BR /&gt;~hope it helps</description>
    <pubDate>Thu, 31 Jan 2008 19:38:33 GMT</pubDate>
    <dc:creator>Sandman!</dc:creator>
    <dc:date>2008-01-31T19:38:33Z</dc:date>
    <item>
      <title>Reformatting Text with AWK.</title>
      <link>https://community.hpe.com/t5/operating-system-linux/reformatting-text-with-awk/m-p/5090607#M93281</link>
      <description>Next dilemma, &lt;BR /&gt;&lt;BR /&gt;user is generating a file. &lt;BR /&gt;&lt;BR /&gt;"Whitman, Slim J",slim@HOTMAIL.COM,Public Schools,01/17/2008,60,&lt;BR /&gt;&lt;BR /&gt;Supposed to be "CSV", however, format "" FULLNAME&lt;BR /&gt;&lt;BR /&gt;I need to grab only email, district, date, and score. &lt;BR /&gt;&lt;BR /&gt;Used following command: &lt;BR /&gt;awk -F'"' '{print $3, $4, $5, $6, $7}' filename.csv &amp;gt; outputfilename.csv &lt;BR /&gt;&lt;BR /&gt;Since the "Full Name" is encapulated in "" I had to use -F'"' to leave the comma in place, if I use ',' it removes all commas. &lt;BR /&gt; &lt;BR /&gt;Get following: &lt;BR /&gt;,slim@HOTMAIL.COM,Public Schools,01/17/2008,60,&lt;BR /&gt;&lt;BR /&gt;Don't need leading comma.. &lt;BR /&gt;&lt;BR /&gt;Any thoughts appreciated. &lt;BR /&gt;&lt;BR /&gt;Rex M</description>
      <pubDate>Thu, 31 Jan 2008 19:12:37 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/reformatting-text-with-awk/m-p/5090607#M93281</guid>
      <dc:creator>rmueller58</dc:creator>
      <dc:date>2008-01-31T19:12:37Z</dc:date>
    </item>
    <item>
      <title>Re: Reformatting Text with AWK.</title>
      <link>https://community.hpe.com/t5/operating-system-linux/reformatting-text-with-awk/m-p/5090608#M93282</link>
      <description>Hi:&lt;BR /&gt;&lt;BR /&gt;Well, if the leading comma is your only requirement to remove:&lt;BR /&gt;&lt;BR /&gt;# awk -F'"' '{print substr($3,2),$4,$5,$6,$7}'&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Thu, 31 Jan 2008 19:28:34 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/reformatting-text-with-awk/m-p/5090608#M93282</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2008-01-31T19:28:34Z</dc:date>
    </item>
    <item>
      <title>Re: Reformatting Text with AWK.</title>
      <link>https://community.hpe.com/t5/operating-system-linux/reformatting-text-with-awk/m-p/5090609#M93283</link>
      <description>awk -F'"' '{print $3, $4, $5, $6, $7}' filename.csv &amp;gt; outputfilename.csv &lt;BR /&gt;&lt;BR /&gt;given the FS is a double qoute, then you really only needed to print $3, as the *first* field is null (line begins w/ separator), the second field is now the full name, and the 3rd field is the rest of the line.&lt;BR /&gt;&lt;BR /&gt;if you are absolutely positive that the name field will always have a comma in it, the following will work:&lt;BR /&gt;&lt;BR /&gt;awk -F, -v OFS=, '{print $3,$4,$5,$6}'&lt;BR /&gt;&lt;BR /&gt;if there is a case where there that can't be relied on, then the following will work as long as the name is surrounded by quotes:&lt;BR /&gt;&lt;BR /&gt;cut -f 3 -d'"' filename.csv | sed -e 's/^,//g' -e 's/,$//g' &amp;gt; outputfilename.csv</description>
      <pubDate>Thu, 31 Jan 2008 19:38:20 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/reformatting-text-with-awk/m-p/5090609#M93283</guid>
      <dc:creator>OldSchool</dc:creator>
      <dc:date>2008-01-31T19:38:20Z</dc:date>
    </item>
    <item>
      <title>Re: Reformatting Text with AWK.</title>
      <link>https://community.hpe.com/t5/operating-system-linux/reformatting-text-with-awk/m-p/5090610#M93284</link>
      <description>Try the awk construct below. It uses a comma as the field delimiter and the output can still be CSV as long as the OFS (output field separator) variable which is internal to awk(1) is set to a comma i.e.&lt;BR /&gt;&lt;BR /&gt;# cat file&lt;BR /&gt;"Whitman, Slim J",slim@HOTMAIL.COM,Public Schools,01/17/2008,60,&lt;BR /&gt;&lt;BR /&gt;# awk -F, '{OFS=",";print $3,$4,$5,$6}' file&lt;BR /&gt;slim@HOTMAIL.COM,Public Schools,01/17/2008,60&lt;BR /&gt;&lt;BR /&gt;~hope it helps</description>
      <pubDate>Thu, 31 Jan 2008 19:38:33 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/reformatting-text-with-awk/m-p/5090610#M93284</guid>
      <dc:creator>Sandman!</dc:creator>
      <dc:date>2008-01-31T19:38:33Z</dc:date>
    </item>
    <item>
      <title>Re: Reformatting Text with AWK.</title>
      <link>https://community.hpe.com/t5/operating-system-linux/reformatting-text-with-awk/m-p/5090611#M93285</link>
      <description>Thanks all, &lt;BR /&gt;&lt;BR /&gt;Got it working. &lt;BR /&gt;&lt;BR /&gt;no offense to Sandman and oldschool I used Jim's coding. The others worked as well for any one whose curious. &lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 31 Jan 2008 19:48:22 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/reformatting-text-with-awk/m-p/5090611#M93285</guid>
      <dc:creator>rmueller58</dc:creator>
      <dc:date>2008-01-31T19:48:22Z</dc:date>
    </item>
    <item>
      <title>Re: Reformatting Text with AWK.</title>
      <link>https://community.hpe.com/t5/operating-system-linux/reformatting-text-with-awk/m-p/5090612#M93286</link>
      <description>Thanks All.</description>
      <pubDate>Thu, 31 Jan 2008 19:49:08 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/reformatting-text-with-awk/m-p/5090612#M93286</guid>
      <dc:creator>rmueller58</dc:creator>
      <dc:date>2008-01-31T19:49:08Z</dc:date>
    </item>
    <item>
      <title>Re: Reformatting Text with AWK.</title>
      <link>https://community.hpe.com/t5/operating-system-linux/reformatting-text-with-awk/m-p/5090613#M93287</link>
      <description>Hi (again):&lt;BR /&gt;&lt;BR /&gt;NO POINTS FOR THIS...&lt;BR /&gt;&lt;BR /&gt;Sandman's code is really an improvement over mine.  His trims the trailing comma, too.  My suggestion merely addressed the fundamental question you asked.&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 31 Jan 2008 19:53:23 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/reformatting-text-with-awk/m-p/5090613#M93287</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2008-01-31T19:53:23Z</dc:date>
    </item>
  </channel>
</rss>

