<?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 help needed in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-help-needed/m-p/3374011#M869084</link>
    <description>Hi,&lt;BR /&gt;&lt;BR /&gt; cat in.txt | awk -F / 'BEGIN {cnt=0} {cnt+=1; if (cnt &amp;lt; 6) {printf "%s ",$2;} else {cnt=0; printf "%s\n",$2;}} END {printf "\n"}'&lt;BR /&gt;&lt;BR /&gt;HTH,&lt;BR /&gt;Peter</description>
    <pubDate>Wed, 08 Sep 2004 00:23:17 GMT</pubDate>
    <dc:creator>Hoefnix</dc:creator>
    <dc:date>2004-09-08T00:23:17Z</dc:date>
    <item>
      <title>awk help needed</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-help-needed/m-p/3374008#M869081</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;I am trying to write a script that will stagger the output below 6 fields accross separated by white spaces then create a new line until all of stdout has been appended in this format to a file.&lt;BR /&gt;&lt;BR /&gt;example of output to be formatted... (only the file names field are to be formatted).&lt;BR /&gt;&lt;BR /&gt;[root@melhpux3] /home/beala01-&amp;gt; du -sk ./*&lt;BR /&gt;7       ./Navimon.cfg&lt;BR /&gt;651     ./RPGC.prn&lt;BR /&gt;5       ./agent.config&lt;BR /&gt;8       ./audit-hpux-10092003.sh&lt;BR /&gt;29      ./benstat-dc.pri&lt;BR /&gt;2       ./bin/&lt;BR /&gt;7       ./class-users.csv&lt;BR /&gt;0       ./crap.out&lt;BR /&gt;0       ./crap/&lt;BR /&gt;1       ./default&lt;BR /&gt;7467    ./emcgrab/&lt;BR /&gt;1525    ./emcgrab_HP-UX_v3.4_1.tar&lt;BR /&gt;59      ./fileset-state.doc&lt;BR /&gt;107     ./fileset.doc&lt;BR /&gt;17      ./jaf.etp&lt;BR /&gt;4       ./nportids&lt;BR /&gt;6       ./p143027b.src&lt;BR /&gt;71      ./passwd&lt;BR /&gt;1       ./payroll-users.csv&lt;BR /&gt;370     ./scripts/&lt;BR /&gt;35030   ./spancustom.tar&lt;BR /&gt;4170    ./spo740c.tar&lt;BR /&gt;1       ./stuff.txt&lt;BR /&gt;22      ./superb-users.csv&lt;BR /&gt;1       ./supero-users.csv&lt;BR /&gt;3       ./tmp/&lt;BR /&gt;1       ./wp-testing.txt&lt;BR /&gt;157     ./wp/&lt;BR /&gt;&lt;BR /&gt;desired output...&lt;BR /&gt;&lt;BR /&gt;[root@melhpux3] /home/beala01-&amp;gt; ls&lt;BR /&gt;.Xauthority               RPGC.prn &lt;BR /&gt;.cshrc                    agent.config &lt;BR /&gt;.jpiu                     benstat-dc.pri&lt;BR /&gt;&lt;BR /&gt;etc...&lt;BR /&gt;&lt;BR /&gt;If there is some way to do this in awk, i would appreciate your help.&lt;BR /&gt;&lt;BR /&gt;Thanks in advance :)&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 07 Sep 2004 22:22:43 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-help-needed/m-p/3374008#M869081</guid>
      <dc:creator>Andrew Beal</dc:creator>
      <dc:date>2004-09-07T22:22:43Z</dc:date>
    </item>
    <item>
      <title>Re: awk help needed</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-help-needed/m-p/3374009#M869082</link>
      <description>The solution should be something like this:&lt;BR /&gt;&lt;BR /&gt;ls | awk '{printf "%s",$0 ; if (NR % 6) {printf "\t";} else {printf "\n"}} END {printf "\n"}'&lt;BR /&gt;&lt;BR /&gt;Or, if you want it better looking, but only if your columns are not too wide:&lt;BR /&gt;ls | awk '{ printf "%-15s",$0 ; if ((NR % 6) == 0) { printf "\n";}} END {printf "\n"}'&lt;BR /&gt;&lt;BR /&gt;You can alter the columnwidth in the printf here, and the number of columns is the 6, used with the modulo sign (%).&lt;BR /&gt;&lt;BR /&gt;(Of course it can be shorter, for instance replace printf "\n" with print ""..)</description>
      <pubDate>Wed, 08 Sep 2004 00:18:52 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-help-needed/m-p/3374009#M869082</guid>
      <dc:creator>Elmar P. Kolkman</dc:creator>
      <dc:date>2004-09-08T00:18:52Z</dc:date>
    </item>
    <item>
      <title>Re: awk help needed</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-help-needed/m-p/3374010#M869083</link>
      <description>ls will try to display the informations in the current directory and du will try do everything under the current directory.&lt;BR /&gt;&lt;BR /&gt;To get at more behaviour of ls with du then,&lt;BR /&gt;&lt;BR /&gt;du -a | awk '{ print $2 }' | sed -e 's/^\.\///;s/\/[^ ]*$//' | sort -u&lt;BR /&gt;&lt;BR /&gt;ls will display file as,&lt;BR /&gt;&lt;BR /&gt;1  3  5  7 &lt;BR /&gt;2  4  6  8&lt;BR /&gt;&lt;BR /&gt;the order may be changed depends up on the files count there.&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Wed, 08 Sep 2004 00:20:01 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-help-needed/m-p/3374010#M869083</guid>
      <dc:creator>Muthukumar_5</dc:creator>
      <dc:date>2004-09-08T00:20:01Z</dc:date>
    </item>
    <item>
      <title>Re: awk help needed</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-help-needed/m-p/3374011#M869084</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt; cat in.txt | awk -F / 'BEGIN {cnt=0} {cnt+=1; if (cnt &amp;lt; 6) {printf "%s ",$2;} else {cnt=0; printf "%s\n",$2;}} END {printf "\n"}'&lt;BR /&gt;&lt;BR /&gt;HTH,&lt;BR /&gt;Peter</description>
      <pubDate>Wed, 08 Sep 2004 00:23:17 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-help-needed/m-p/3374011#M869084</guid>
      <dc:creator>Hoefnix</dc:creator>
      <dc:date>2004-09-08T00:23:17Z</dc:date>
    </item>
    <item>
      <title>Re: awk help needed</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-help-needed/m-p/3374012#M869085</link>
      <description>Thankyou all,&lt;BR /&gt;&lt;BR /&gt;Elmar &amp;amp; Peter, both your commands worked perfectly, and gave the exact output I required!!!&lt;BR /&gt;&lt;BR /&gt;OMG... you have no idea how much pain you guys have saved me!&lt;BR /&gt;&lt;BR /&gt;Muthukumar, I couldn't get your's to work imediatley, but I will fiddle with it a bit.&lt;BR /&gt;&lt;BR /&gt;Thankyou all once again :)</description>
      <pubDate>Wed, 08 Sep 2004 00:39:22 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-help-needed/m-p/3374012#M869085</guid>
      <dc:creator>Andrew Beal</dc:creator>
      <dc:date>2004-09-08T00:39:22Z</dc:date>
    </item>
    <item>
      <title>Re: awk help needed</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-help-needed/m-p/3374013#M869086</link>
      <description>Why not use pr?&lt;BR /&gt;&lt;BR /&gt;# whatever_command | pr -t -a -w78&lt;BR /&gt;&lt;BR /&gt;-t: terminal output&lt;BR /&gt;-a: accross&lt;BR /&gt;-w78: output width&lt;BR /&gt;&lt;BR /&gt;Many more options supported&lt;BR /&gt;&lt;BR /&gt;Enjoy, Have FUN! H.Merijn [ who uses the right function for the job ]</description>
      <pubDate>Wed, 08 Sep 2004 01:15:39 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-help-needed/m-p/3374013#M869086</guid>
      <dc:creator>H.Merijn Brand (procura</dc:creator>
      <dc:date>2004-09-08T01:15:39Z</dc:date>
    </item>
    <item>
      <title>Re: awk help needed</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-help-needed/m-p/3374014#M869087</link>
      <description>I misunderstand that " you want to make du output as like ls output" so why tried with sed + awk there.&lt;BR /&gt;&lt;BR /&gt;I hope you got the awk with king's reply there. But procura's command more good as,&lt;BR /&gt;&lt;BR /&gt;ls | pr -d -c 6&lt;BR /&gt;&lt;BR /&gt; it will give easily.</description>
      <pubDate>Wed, 08 Sep 2004 01:44:33 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-help-needed/m-p/3374014#M869087</guid>
      <dc:creator>Muthukumar_5</dc:creator>
      <dc:date>2004-09-08T01:44:33Z</dc:date>
    </item>
    <item>
      <title>Re: awk help needed</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-help-needed/m-p/3374015#M869088</link>
      <description>Sorry to disagree, but pr doesn't do what you want. In Procura's solution it does not generate 6 columns, and in Muthukumar it will truncate long file names... &lt;BR /&gt;&lt;BR /&gt;Look at this as explanation:&lt;BR /&gt;ptc27b08:/var/adm/syslog # ls | pr -t -d -c 6&lt;BR /&gt;OLDsyslog.l mail.log.2. mail.log.6. syslog.log  syslog.log. syslog.log.&lt;BR /&gt;&lt;BR /&gt;genlog.log  mail.log.3. mail.log.7. syslog.log. syslog.log. syslog.log.&lt;BR /&gt;&lt;BR /&gt;mail.log    mail.log.4. mail.log.8. syslog.log. syslog.log. syslog.logS&lt;BR /&gt;&lt;BR /&gt;mail.log.1. mail.log.5. mail.log.9. syslog.log. syslog.log.&lt;BR /&gt;ptc27b08:/var/adm/syslog # ls&lt;BR /&gt;OLDsyslog.log     mail.log.1.gz     mail.log.4.gz     mail.log.7.gz     syslog.log        syslog.log.3.gz   syslog.log.6.gz   syslog.log.9.gz&lt;BR /&gt;genlog.log        mail.log.2.gz     mail.log.5.gz     mail.log.8.gz     syslog.log.1.gz   syslog.log.4.gz   syslog.log.7.gz   syslog.logSAMTRM&lt;BR /&gt;mail.log          mail.log.3.gz     mail.log.6.gz     mail.log.9.gz     syslog.log.2.gz   syslog.log.5.gz   syslog.log.8.gz&lt;BR /&gt;ptc27b08:/var/adm/syslog # &lt;BR /&gt;</description>
      <pubDate>Wed, 08 Sep 2004 04:14:40 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-help-needed/m-p/3374015#M869088</guid>
      <dc:creator>Elmar P. Kolkman</dc:creator>
      <dc:date>2004-09-08T04:14:40Z</dc:date>
    </item>
    <item>
      <title>Re: awk help needed</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-help-needed/m-p/3374016#M869089</link>
      <description>man tr&lt;BR /&gt;&lt;BR /&gt;I did not give a -# (like -2) argument, because the original statement is not clear enough to me. Neither is the general definition of columned output of ls. There is no `rule' on how many columns ls produces. It depends on -F, using colors, screen width, screen properties (man terminfo look at xmc-cookie-glitch) and many other factors.&lt;BR /&gt;&lt;BR /&gt;if the output of command 'blah' gives you three columns, and you want to make 6 columns where only the last field of each line is reformatted, do&lt;BR /&gt;&lt;BR /&gt;# blah | pr -2 -a -t&lt;BR /&gt;&lt;BR /&gt;Enjoy, Have FUN! H.Merijn</description>
      <pubDate>Wed, 08 Sep 2004 09:38:48 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-help-needed/m-p/3374016#M869089</guid>
      <dc:creator>H.Merijn Brand (procura</dc:creator>
      <dc:date>2004-09-08T09:38:48Z</dc:date>
    </item>
    <item>
      <title>Re: awk help needed</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-help-needed/m-p/3374017#M869090</link>
      <description>But that still does not what you want... If you have long column entries, it still truncates to make 6 columns of equal width. So pr is only usable if you als give a commandline option to set the width to 6 times the lenght of the largest entry plus six, or in formula:&lt;BR /&gt;6*(width + 1)&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 09 Sep 2004 00:08:58 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-help-needed/m-p/3374017#M869090</guid>
      <dc:creator>Elmar P. Kolkman</dc:creator>
      <dc:date>2004-09-09T00:08:58Z</dc:date>
    </item>
    <item>
      <title>Re: awk help needed</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-help-needed/m-p/3374018#M869091</link>
      <description>BTW, Andrew, make sure you keep a good point assignment ratio, you can assign zero points to all my recent replies... They have nothing to do with the question, I just like discussions like this with Merijn ;-)</description>
      <pubDate>Thu, 09 Sep 2004 00:13:33 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-help-needed/m-p/3374018#M869091</guid>
      <dc:creator>Elmar P. Kolkman</dc:creator>
      <dc:date>2004-09-09T00:13:33Z</dc:date>
    </item>
    <item>
      <title>Re: awk help needed</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-help-needed/m-p/3374019#M869092</link>
      <description>kolkman, we can use (merjin's command :)) pr with some width settings to get it to view the long file name's effectively as,&lt;BR /&gt;&lt;BR /&gt;It is good to change the size of -15s to -21s to get long files in a good format as,&lt;BR /&gt;&lt;BR /&gt;#ls | awk '{ printf "%-21s",$0 ; if ((NR % 6) == 0) { printf "\n";}} END {printf "\n"}'&lt;BR /&gt;&lt;BR /&gt;We can get this with the following pr as,&lt;BR /&gt;&lt;BR /&gt;# ls | pr -t -w125 -c 6&lt;BR /&gt;&lt;BR /&gt;And some more options as,&lt;BR /&gt;-ock, etc.. They are good to make this easily.&lt;BR /&gt;&lt;BR /&gt;But ls ordering is lost on piping there when do awk / pr itself.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt; &lt;BR /&gt;</description>
      <pubDate>Thu, 09 Sep 2004 00:48:32 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-help-needed/m-p/3374019#M869092</guid>
      <dc:creator>Muthukumar_5</dc:creator>
      <dc:date>2004-09-09T00:48:32Z</dc:date>
    </item>
  </channel>
</rss>

