<?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: Help with awk. in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/help-with-awk/m-p/4749754#M656399</link>
    <description>Hi,&lt;BR /&gt;&lt;BR /&gt;Please try this:&lt;BR /&gt;[root@test sample]# ls -ltr|tail -4&lt;BR /&gt;&lt;BR /&gt;Rgds.</description>
    <pubDate>Tue, 08 Feb 2011 09:47:59 GMT</pubDate>
    <dc:creator>Jose Mosquera</dc:creator>
    <dc:date>2011-02-08T09:47:59Z</dc:date>
    <item>
      <title>Help with awk.</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/help-with-awk/m-p/4749753#M656398</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;When I do a "ls" in a given directory, I want to parse it so that it prints all the files except the last four:&lt;BR /&gt;&lt;BR /&gt;[root@test sample]# ls -ltr&lt;BR /&gt;total 0&lt;BR /&gt;-rw-r--r-- 1 root root 0 feb  8 08:54 one&lt;BR /&gt;-rw-r--r-- 1 root root 0 feb  8 08:54 two&lt;BR /&gt;-rw-r--r-- 1 root root 0 feb  8 08:55 three&lt;BR /&gt;-rw-r--r-- 1 root root 0 feb  8 08:55 four&lt;BR /&gt;-rw-r--r-- 1 root root 0 feb  8 08:55 five&lt;BR /&gt;-rw-r--r-- 1 root root 0 feb  8 08:55 six&lt;BR /&gt;&lt;BR /&gt;I want it to show all the files but the four most recents, I mean: one and two only.&lt;BR /&gt;&lt;BR /&gt;How can I do this???&lt;BR /&gt;</description>
      <pubDate>Tue, 08 Feb 2011 07:56:50 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/help-with-awk/m-p/4749753#M656398</guid>
      <dc:creator>Juan Antonio Llano</dc:creator>
      <dc:date>2011-02-08T07:56:50Z</dc:date>
    </item>
    <item>
      <title>Re: Help with awk.</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/help-with-awk/m-p/4749754#M656399</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;Please try this:&lt;BR /&gt;[root@test sample]# ls -ltr|tail -4&lt;BR /&gt;&lt;BR /&gt;Rgds.</description>
      <pubDate>Tue, 08 Feb 2011 09:47:59 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/help-with-awk/m-p/4749754#M656399</guid>
      <dc:creator>Jose Mosquera</dc:creator>
      <dc:date>2011-02-08T09:47:59Z</dc:date>
    </item>
    <item>
      <title>Re: Help with awk.</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/help-with-awk/m-p/4749755#M656400</link>
      <description>Hi again,&lt;BR /&gt;Ooops, to show one and two files try:&lt;BR /&gt;[root@test sample]# ls -ltr|head -2&lt;BR /&gt;&lt;BR /&gt;Rgds.</description>
      <pubDate>Tue, 08 Feb 2011 09:51:14 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/help-with-awk/m-p/4749755#M656400</guid>
      <dc:creator>Jose Mosquera</dc:creator>
      <dc:date>2011-02-08T09:51:14Z</dc:date>
    </item>
    <item>
      <title>Re: Help with awk.</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/help-with-awk/m-p/4749756#M656401</link>
      <description>As simple solution in case of you just 2 files, maybe it is better ;&lt;BR /&gt;# ls -lrt |tail -6|head -2&lt;BR /&gt;</description>
      <pubDate>Tue, 08 Feb 2011 12:09:16 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/help-with-awk/m-p/4749756#M656401</guid>
      <dc:creator>Hakki Aydin Ucar</dc:creator>
      <dc:date>2011-02-08T12:09:16Z</dc:date>
    </item>
    <item>
      <title>Re: Help with awk.</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/help-with-awk/m-p/4749757#M656402</link>
      <description>Hi:&lt;BR /&gt;&lt;BR /&gt;&amp;gt; I want it to show all the files but the four most recents, I mean: one and two only.&lt;BR /&gt;&lt;BR /&gt;So you mean only the first two files in the list.  You could do this:&lt;BR /&gt;&lt;BR /&gt;# ls -ltr | awk '!/^total/ &amp;amp;&amp;amp; NR&amp;lt;=3'&lt;BR /&gt;&lt;BR /&gt;...which skips the "total" or first line and then delivers lines two and three which are what you want.&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Tue, 08 Feb 2011 14:19:04 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/help-with-awk/m-p/4749757#M656402</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2011-02-08T14:19:04Z</dc:date>
    </item>
    <item>
      <title>Re: Help with awk.</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/help-with-awk/m-p/4749758#M656403</link>
      <description>&amp;gt;prints all the files except the last four:&lt;BR /&gt;&lt;BR /&gt;Your query doesn't lend itself to any single command.  That's assuming a directory with random number of files.&lt;BR /&gt;&lt;BR /&gt;You could do:&lt;BR /&gt;ls -lt | tail +4&lt;BR /&gt;(Or possibly +5 to remove that total?)&lt;BR /&gt;The files will be in reverse order, two then one.&lt;BR /&gt;&lt;BR /&gt;Otherwise you would have to put the output in a file and then count the lines before printing them.  (Or you could do multiple ls(1) commands.)&lt;BR /&gt;&lt;BR /&gt;Or you could have a complex awk script that buffers up the last 4 lines and if more, then print the first. And upon EOF, don't print those 4 lines.</description>
      <pubDate>Tue, 08 Feb 2011 14:29:01 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/help-with-awk/m-p/4749758#M656403</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2011-02-08T14:29:01Z</dc:date>
    </item>
    <item>
      <title>Re: Help with awk.</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/help-with-awk/m-p/4749759#M656404</link>
      <description>&amp;gt;ME: Or possibly +5 to remove that total?&lt;BR /&gt;&lt;BR /&gt;You need +6 to skip total line and 4 more:&lt;BR /&gt;ls -lt | tail +$(( 4 + 2 ))</description>
      <pubDate>Wed, 09 Feb 2011 00:07:36 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/help-with-awk/m-p/4749759#M656404</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2011-02-09T00:07:36Z</dc:date>
    </item>
  </channel>
</rss>

