<?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 awk and printf in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-and-printf/m-p/3463681#M210528</link>
    <description>Hi ,&lt;BR /&gt;&lt;BR /&gt;I am trying to format a log file .I need a aligned 4 column o/p .Sample of the log file is attached.&lt;BR /&gt;&lt;BR /&gt;I am using cat sample.txt |awk -F"|" '{printf "%10s %-20s %20-s %20-s", $1,$2,$3,$4}'&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;But Its not able to format the o/p in columnvice.&lt;BR /&gt;&lt;BR /&gt;Can you pls help.&lt;BR /&gt;&lt;BR /&gt;Thanks&lt;BR /&gt;</description>
    <pubDate>Fri, 14 Jan 2005 15:51:45 GMT</pubDate>
    <dc:creator>baiju_3</dc:creator>
    <dc:date>2005-01-14T15:51:45Z</dc:date>
    <item>
      <title>awk and printf</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-and-printf/m-p/3463681#M210528</link>
      <description>Hi ,&lt;BR /&gt;&lt;BR /&gt;I am trying to format a log file .I need a aligned 4 column o/p .Sample of the log file is attached.&lt;BR /&gt;&lt;BR /&gt;I am using cat sample.txt |awk -F"|" '{printf "%10s %-20s %20-s %20-s", $1,$2,$3,$4}'&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;But Its not able to format the o/p in columnvice.&lt;BR /&gt;&lt;BR /&gt;Can you pls help.&lt;BR /&gt;&lt;BR /&gt;Thanks&lt;BR /&gt;</description>
      <pubDate>Fri, 14 Jan 2005 15:51:45 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-and-printf/m-p/3463681#M210528</guid>
      <dc:creator>baiju_3</dc:creator>
      <dc:date>2005-01-14T15:51:45Z</dc:date>
    </item>
    <item>
      <title>Re: awk and printf</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-and-printf/m-p/3463682#M210529</link>
      <description>You are close; your main problem is lack of a linefeed ("\n") and a little better printf formatting is needed:&lt;BR /&gt;&lt;BR /&gt;awk -F '|' '{printf("%-10.10s %-20.20s %-20.20s %-20.20s\n",$1,$2,$3,$4)}' sample.txt&lt;BR /&gt; &lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Fri, 14 Jan 2005 16:03:02 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-and-printf/m-p/3463682#M210529</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2005-01-14T16:03:02Z</dc:date>
    </item>
    <item>
      <title>Re: awk and printf</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-and-printf/m-p/3463683#M210530</link>
      <description>Hi Clay Stephenson   ,&lt;BR /&gt;&lt;BR /&gt;\n I was using forgot to type .&lt;BR /&gt;&lt;BR /&gt;It has not given me the required o/p .&lt;BR /&gt;Can you please try this on the sample.txt attached.&lt;BR /&gt;&lt;BR /&gt;Thanks,&lt;BR /&gt;Baiju.</description>
      <pubDate>Fri, 14 Jan 2005 16:23:22 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-and-printf/m-p/3463683#M210530</guid>
      <dc:creator>baiju_3</dc:creator>
      <dc:date>2005-01-14T16:23:22Z</dc:date>
    </item>
    <item>
      <title>Re: awk and printf</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-and-printf/m-p/3463684#M210531</link>
      <description>My version works perfectly for me using your input file. I do note that very few of your input lines have all four fields with non-whitespace values. It would help if you list a sample line of input followed by your desired output. You should also note that your attached file had CR's which I assume the original UNIX output did not have.</description>
      <pubDate>Fri, 14 Jan 2005 16:34:36 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-and-printf/m-p/3463684#M210531</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2005-01-14T16:34:36Z</dc:date>
    </item>
    <item>
      <title>Re: awk and printf</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-and-printf/m-p/3463685#M210532</link>
      <description>&lt;BR /&gt;Control char might have added during copy paste to ITRC.&lt;BR /&gt;&lt;BR /&gt;The o/p which I was looking for is attached .&lt;BR /&gt;&lt;BR /&gt;Still no progress for me.</description>
      <pubDate>Fri, 14 Jan 2005 16:53:21 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-and-printf/m-p/3463685#M210532</guid>
      <dc:creator>baiju_3</dc:creator>
      <dc:date>2005-01-14T16:53:21Z</dc:date>
    </item>
    <item>
      <title>Re: awk and printf</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-and-printf/m-p/3463686#M210533</link>
      <description>Well, I have no idea what your problem is but I spent about 4 minutes throwing together a script and tested it against your sample.txt.&lt;BR /&gt;&lt;BR /&gt;Please see the attached file which contains both the script and the output.&lt;BR /&gt;&lt;BR /&gt;After you yank out the script, chmod 777 my.sh and then&lt;BR /&gt;my.sh &amp;lt; sample.txt &amp;gt; out.txt&lt;BR /&gt;</description>
      <pubDate>Fri, 14 Jan 2005 17:37:59 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-and-printf/m-p/3463686#M210533</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2005-01-14T17:37:59Z</dc:date>
    </item>
    <item>
      <title>Re: awk and printf</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-and-printf/m-p/3463687#M210534</link>
      <description>&lt;BR /&gt;You need to eat the spaces somehow.&lt;BR /&gt;The can be done with a replace in the 'code',&lt;BR /&gt;or they can be sucked into the ERE for the seperator. Try:&lt;BR /&gt;&lt;BR /&gt; awk -F " *[|] *" '{printf "%10s %-20s %-20s %-20s\n", $1,$2,$3,$4}' &lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;The ERE is &lt;BR /&gt;- a space followed by an asterix for zero or more spaces.&lt;BR /&gt;followed by&lt;BR /&gt;- a boxed in |. I had to do this to avoid the bar becoming an 'or'&lt;BR /&gt;followed y zero or more spaces.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Cheers,&lt;BR /&gt;Hein.&lt;BR /&gt;</description>
      <pubDate>Fri, 14 Jan 2005 23:03:14 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-and-printf/m-p/3463687#M210534</guid>
      <dc:creator>Hein van den Heuvel</dc:creator>
      <dc:date>2005-01-14T23:03:14Z</dc:date>
    </item>
  </channel>
</rss>

