<?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: Problems with PRINTF... in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/problems-with-printf/m-p/2831266#M721145</link>
    <description>Hi Mike,&lt;BR /&gt;&lt;BR /&gt;One way to do it is with awk.  With printf, you specify the type of field and the length of the field.  For strings, you use the %s parameter.  For numbers, you have several choices, but you'll probably want the %d parameter for decimal integers.  Something like this might work:&lt;BR /&gt;&lt;BR /&gt;awk '{printf("%20s %6d %6d %6d %6d %6d %6d\n", $1, $2, $3, $4, $5, $6, $7)}' myfile&lt;BR /&gt;&lt;BR /&gt;The \n adds a new line.  You can also use \t to insert tab characters, but specifying the field lengths usually makes things print pretty cleanly without any tabs.&lt;BR /&gt;&lt;BR /&gt;I know you can use printf in shell scripts but I haven't played with it.  The printf in awk is pretty much like the one in C and Perl, and it gets the job done for me.&lt;BR /&gt;&lt;BR /&gt;JP&lt;BR /&gt;</description>
    <pubDate>Tue, 22 Oct 2002 23:11:35 GMT</pubDate>
    <dc:creator>John Poff</dc:creator>
    <dc:date>2002-10-22T23:11:35Z</dc:date>
    <item>
      <title>Problems with PRINTF...</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/problems-with-printf/m-p/2831265#M721144</link>
      <description>Hey All,&lt;BR /&gt;&lt;BR /&gt;I have a text document that has 7 columns. The document is a result of echo'ing a group of variables. The document has up to 100 lines, but when I view the data it is not aligned great. It is all jagged and over the place, making it hard to view. Someone has told me that I can use PRINTF to specify column widths and tab delimeters to clean things up, but after revewing the man pages on PRINTF I am lost. Is there anyone that can help me??&lt;BR /&gt;&lt;BR /&gt;Thanks,&lt;BR /&gt;Mike Button&lt;BR /&gt;&lt;BR /&gt;P.S. The columns are like this.&lt;BR /&gt;1 -&amp;gt; string &lt;BR /&gt;2 - 7 -&amp;gt; numeric (1 -5 max per column)</description>
      <pubDate>Tue, 22 Oct 2002 23:03:11 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/problems-with-printf/m-p/2831265#M721144</guid>
      <dc:creator>Mike Button</dc:creator>
      <dc:date>2002-10-22T23:03:11Z</dc:date>
    </item>
    <item>
      <title>Re: Problems with PRINTF...</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/problems-with-printf/m-p/2831266#M721145</link>
      <description>Hi Mike,&lt;BR /&gt;&lt;BR /&gt;One way to do it is with awk.  With printf, you specify the type of field and the length of the field.  For strings, you use the %s parameter.  For numbers, you have several choices, but you'll probably want the %d parameter for decimal integers.  Something like this might work:&lt;BR /&gt;&lt;BR /&gt;awk '{printf("%20s %6d %6d %6d %6d %6d %6d\n", $1, $2, $3, $4, $5, $6, $7)}' myfile&lt;BR /&gt;&lt;BR /&gt;The \n adds a new line.  You can also use \t to insert tab characters, but specifying the field lengths usually makes things print pretty cleanly without any tabs.&lt;BR /&gt;&lt;BR /&gt;I know you can use printf in shell scripts but I haven't played with it.  The printf in awk is pretty much like the one in C and Perl, and it gets the job done for me.&lt;BR /&gt;&lt;BR /&gt;JP&lt;BR /&gt;</description>
      <pubDate>Tue, 22 Oct 2002 23:11:35 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/problems-with-printf/m-p/2831266#M721145</guid>
      <dc:creator>John Poff</dc:creator>
      <dc:date>2002-10-22T23:11:35Z</dc:date>
    </item>
    <item>
      <title>Re: Problems with PRINTF...</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/problems-with-printf/m-p/2831267#M721146</link>
      <description>Thanks for the suggestion, but after trying it, why I get is one line from my document and then one line that looks like this, 20s %6d %6d %6d %6d %6d %6d&lt;BR /&gt;&lt;BR /&gt;Any suggestion, here is my command:&lt;BR /&gt;&lt;BR /&gt;awk '{print ("20s %6d %6d %6d %6d %6d %6d\n", $1, $2, $3, $4, $5, $6, $7)}' myfile &amp;gt;myfile2</description>
      <pubDate>Tue, 22 Oct 2002 23:21:22 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/problems-with-printf/m-p/2831267#M721146</guid>
      <dc:creator>Mike Button</dc:creator>
      <dc:date>2002-10-22T23:21:22Z</dc:date>
    </item>
    <item>
      <title>Re: Problems with PRINTF...</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/problems-with-printf/m-p/2831268#M721147</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;You typed 'print' instead of 'printf', and your first parameter should be %20s instead of just 20s.  Try it that way and see what you get.&lt;BR /&gt;&lt;BR /&gt;JP&lt;BR /&gt;</description>
      <pubDate>Tue, 22 Oct 2002 23:22:49 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/problems-with-printf/m-p/2831268#M721147</guid>
      <dc:creator>John Poff</dc:creator>
      <dc:date>2002-10-22T23:22:49Z</dc:date>
    </item>
    <item>
      <title>Re: Problems with PRINTF...</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/problems-with-printf/m-p/2831269#M721148</link>
      <description>Ever have one of those days...Thanks a lot...Things look great.&lt;BR /&gt;&lt;BR /&gt;Mike</description>
      <pubDate>Tue, 22 Oct 2002 23:24:28 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/problems-with-printf/m-p/2831269#M721148</guid>
      <dc:creator>Mike Button</dc:creator>
      <dc:date>2002-10-22T23:24:28Z</dc:date>
    </item>
    <item>
      <title>Re: Problems with PRINTF...</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/problems-with-printf/m-p/2831270#M721149</link>
      <description>Hi Mike,&lt;BR /&gt;  You don't have to do that in awk, you can do the same thing in your C program.&lt;BR /&gt;&lt;BR /&gt;printf("%20s%7d\n", mystring, myint); &lt;BR /&gt;&lt;BR /&gt;  will put the string right justified starting at the 20th column and the integer at right justified at the 17th column.</description>
      <pubDate>Wed, 23 Oct 2002 23:44:19 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/problems-with-printf/m-p/2831270#M721149</guid>
      <dc:creator>susan gregory_1</dc:creator>
      <dc:date>2002-10-23T23:44:19Z</dc:date>
    </item>
  </channel>
</rss>

