<?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: Colunm formating in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/colunm-formating/m-p/3156224#M901845</link>
    <description>Here's one pure shell method:&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt;&lt;BR /&gt;VAR="01 02 03 04 05 06 07 08 09 10 11"&lt;BR /&gt;set ${VAR}&lt;BR /&gt;while [[ ${#} -gt 0 ]]&lt;BR /&gt;  do&lt;BR /&gt;     typeset -i10 KNT=0&lt;BR /&gt;     while [[ ${KNT} -lt 4 &amp;amp;&amp;amp; ${#} -gt 0 ]]&lt;BR /&gt;       do&lt;BR /&gt;          echo "${1}\t\c"&lt;BR /&gt;          shift&lt;BR /&gt;          ((KNT += 1))&lt;BR /&gt;       done&lt;BR /&gt;     echo&lt;BR /&gt;  done&lt;BR /&gt;&lt;BR /&gt;You probably would want to make a function out of this to call it with multiple variables.&lt;BR /&gt;</description>
    <pubDate>Mon, 05 Jan 2004 12:01:32 GMT</pubDate>
    <dc:creator>A. Clay Stephenson</dc:creator>
    <dc:date>2004-01-05T12:01:32Z</dc:date>
    <item>
      <title>Colunm formating</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/colunm-formating/m-p/3156220#M901841</link>
      <description>Hi pals,&lt;BR /&gt;&lt;BR /&gt;Pls a *easier* way to echo a $VAR content in n colummns, i.e:&lt;BR /&gt;&lt;BR /&gt;VAR="01 02 03 04 05 06 07 08 09 10 11"&lt;BR /&gt;I need echo $VAR up to four columns format:&lt;BR /&gt;01 02 03 04&lt;BR /&gt;05 06 07 08&lt;BR /&gt;09 10 11&lt;BR /&gt;&lt;BR /&gt;BR,</description>
      <pubDate>Mon, 05 Jan 2004 11:39:00 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/colunm-formating/m-p/3156220#M901841</guid>
      <dc:creator>Jose Mosquera</dc:creator>
      <dc:date>2004-01-05T11:39:00Z</dc:date>
    </item>
    <item>
      <title>Re: Colunm formating</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/colunm-formating/m-p/3156221#M901842</link>
      <description>use "cut"&lt;BR /&gt;&lt;BR /&gt;$ echo $VAR&lt;BR /&gt;1 2 3 4 5 6 7 8 9 10&lt;BR /&gt;$ echo $VAR | cut -f 1-3 -d\ 1-3&lt;BR /&gt;1 2 3&lt;BR /&gt;&lt;BR /&gt;repeat "cut" as necessary to obtain the desidered output.&lt;BR /&gt;&lt;BR /&gt;  HTH,&lt;BR /&gt;    Massimo&lt;BR /&gt;</description>
      <pubDate>Mon, 05 Jan 2004 11:47:23 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/colunm-formating/m-p/3156221#M901842</guid>
      <dc:creator>Massimo Bianchi</dc:creator>
      <dc:date>2004-01-05T11:47:23Z</dc:date>
    </item>
    <item>
      <title>Re: Colunm formating</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/colunm-formating/m-p/3156222#M901843</link>
      <description>In your shell file put in a line that says:&lt;BR /&gt;&lt;BR /&gt;echo $VAR | awk -f useme.awk&lt;BR /&gt;&lt;BR /&gt;Create a file called useme.awk which contains a SINGLE LINE (you may have to join lines after you cut and paste) that has this in it:&lt;BR /&gt;&lt;BR /&gt;{for (idx1=1;idx1&amp;lt;=NF;idx1++) { printf ("%3s",$idx1); if ((idx1%4==0)||(idx1==NF&lt;BR /&gt;)) {printf ("\n");} } } &lt;BR /&gt;&lt;BR /&gt;Note, the "3s" is making columns three spaces wide.  If you want it to just have the columns be the width of your data then take out the "3".  If you want the data columns wider then change the "3" to whatever width column you want.&lt;BR /&gt;&lt;BR /&gt;Best regards,&lt;BR /&gt;&lt;BR /&gt;Kent M. Ostby&lt;BR /&gt;</description>
      <pubDate>Mon, 05 Jan 2004 11:52:18 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/colunm-formating/m-p/3156222#M901843</guid>
      <dc:creator>Kent Ostby</dc:creator>
      <dc:date>2004-01-05T11:52:18Z</dc:date>
    </item>
    <item>
      <title>Re: Colunm formating</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/colunm-formating/m-p/3156223#M901844</link>
      <description>Thanks Massimo,&lt;BR /&gt;&lt;BR /&gt;I need it in a single sweep.&lt;BR /&gt;&lt;BR /&gt;BR,</description>
      <pubDate>Mon, 05 Jan 2004 11:52:36 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/colunm-formating/m-p/3156223#M901844</guid>
      <dc:creator>Jose Mosquera</dc:creator>
      <dc:date>2004-01-05T11:52:36Z</dc:date>
    </item>
    <item>
      <title>Re: Colunm formating</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/colunm-formating/m-p/3156224#M901845</link>
      <description>Here's one pure shell method:&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt;&lt;BR /&gt;VAR="01 02 03 04 05 06 07 08 09 10 11"&lt;BR /&gt;set ${VAR}&lt;BR /&gt;while [[ ${#} -gt 0 ]]&lt;BR /&gt;  do&lt;BR /&gt;     typeset -i10 KNT=0&lt;BR /&gt;     while [[ ${KNT} -lt 4 &amp;amp;&amp;amp; ${#} -gt 0 ]]&lt;BR /&gt;       do&lt;BR /&gt;          echo "${1}\t\c"&lt;BR /&gt;          shift&lt;BR /&gt;          ((KNT += 1))&lt;BR /&gt;       done&lt;BR /&gt;     echo&lt;BR /&gt;  done&lt;BR /&gt;&lt;BR /&gt;You probably would want to make a function out of this to call it with multiple variables.&lt;BR /&gt;</description>
      <pubDate>Mon, 05 Jan 2004 12:01:32 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/colunm-formating/m-p/3156224#M901845</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2004-01-05T12:01:32Z</dc:date>
    </item>
    <item>
      <title>Re: Colunm formating</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/colunm-formating/m-p/3156225#M901846</link>
      <description>strange that no one has mentioned good old fold yet?&lt;BR /&gt;&lt;BR /&gt;e.g.&lt;BR /&gt;&lt;BR /&gt;suppose you have only two digit wide columns,&lt;BR /&gt;how about something like this&lt;BR /&gt;&lt;BR /&gt;$ var="12 43 28 29 23 21 38 21 93 21 29 29 39 29"&lt;BR /&gt;$ echo $var|fold -w 12&lt;BR /&gt;12 43 28 29 &lt;BR /&gt;23 21 38 21 &lt;BR /&gt;93 21 29 29 &lt;BR /&gt;39 29&lt;BR /&gt;$ &lt;BR /&gt;</description>
      <pubDate>Mon, 05 Jan 2004 12:17:49 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/colunm-formating/m-p/3156225#M901846</guid>
      <dc:creator>Ralph Grothe</dc:creator>
      <dc:date>2004-01-05T12:17:49Z</dc:date>
    </item>
    <item>
      <title>Re: Colunm formating</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/colunm-formating/m-p/3156226#M901847</link>
      <description>use "xargs"-&lt;BR /&gt; &lt;BR /&gt;echo $VAR | xargs -n4 echo&lt;BR /&gt; &lt;BR /&gt;Just specify number of columns on -n parameter.&lt;BR /&gt; &lt;BR /&gt;HTH&lt;BR /&gt; &lt;BR /&gt;-- Rod Hills</description>
      <pubDate>Mon, 05 Jan 2004 12:41:09 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/colunm-formating/m-p/3156226#M901847</guid>
      <dc:creator>Rodney Hills</dc:creator>
      <dc:date>2004-01-05T12:41:09Z</dc:date>
    </item>
    <item>
      <title>Re: Colunm formating</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/colunm-formating/m-p/3156227#M901848</link>
      <description>Here is a pretty silly solution in perl.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt; perl -e '$_=$ENV{"var"}; s/(\S+\s+\S+\s+\S+\s+\S+)\s+/$1\n/g; print "$_\n"'&lt;BR /&gt;&lt;BR /&gt;or similar to the awk solution is:&lt;BR /&gt;&lt;BR /&gt;echo $var | perl -e 'foreach $w (split(/ /,&amp;lt;&amp;gt;)){$s=(++$i % 4)?" ":"\n"; print "$w$s"}'&lt;BR /&gt;&lt;BR /&gt;Or...&lt;BR /&gt;&lt;BR /&gt;export $var&lt;BR /&gt;perl -e 'foreach $w (split (/ /,$ENV{"var"})) {$s=(++$i % 4)?" ":"\n"; print "$w$s"}'&lt;BR /&gt;&lt;BR /&gt;I tried it in sed, but inserting a newline is too ugly for my taste for lack of a \n.&lt;BR /&gt;You have to use multiple lines. Some like&lt;BR /&gt;&lt;BR /&gt;echo $var | sed -e "s/ /\\&lt;BR /&gt;/4" -e "s/ /\\&lt;BR /&gt;/7" -e "s/ /\\&lt;BR /&gt;/10"&lt;BR /&gt;&lt;BR /&gt;Or very ugly with a post-translated helper character "q":&lt;BR /&gt;&lt;BR /&gt;echo $var | sed -e "s/ /q/4"  -e "s/ /q/7" -e "s/ /q/10" | tr q \\012&lt;BR /&gt;</description>
      <pubDate>Wed, 07 Jan 2004 03:14:36 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/colunm-formating/m-p/3156227#M901848</guid>
      <dc:creator>Hein van den Heuvel</dc:creator>
      <dc:date>2004-01-07T03:14:36Z</dc:date>
    </item>
    <item>
      <title>Re: Colunm formating</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/colunm-formating/m-p/3156228#M901849</link>
      <description>Better way with sed:&lt;BR /&gt;print $(echo $VAR | sed 's|\([^ ]* [^ ]* [^ ]* [^ ]*\) |\1\\n|g')&lt;BR /&gt;&lt;BR /&gt;The sed command will replace every fourth space to '\n' which will be interpretted by print as a newline...</description>
      <pubDate>Wed, 07 Jan 2004 03:29:07 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/colunm-formating/m-p/3156228#M901849</guid>
      <dc:creator>Elmar P. Kolkman</dc:creator>
      <dc:date>2004-01-07T03:29:07Z</dc:date>
    </item>
    <item>
      <title>Re: Colunm formating</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/colunm-formating/m-p/3156229#M901850</link>
      <description>Thanks! I now see how I can get a substituted 'normal' "\n" to turn into a newline throug print. Cheers, Hein.&lt;BR /&gt;</description>
      <pubDate>Wed, 07 Jan 2004 10:10:19 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/colunm-formating/m-p/3156229#M901850</guid>
      <dc:creator>Hein van den Heuvel</dc:creator>
      <dc:date>2004-01-07T10:10:19Z</dc:date>
    </item>
  </channel>
</rss>

