<?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 script shell in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/script-shell/m-p/2844011#M721300</link>
    <description>Hi All!&lt;BR /&gt; help me please,&lt;BR /&gt; I get the script that list contents of dir, but I need to limit by number of files.&lt;BR /&gt;In other words: &lt;BR /&gt;I have 10 files in /ttp,&lt;BR /&gt;I want to move only the last 5 new. I'm using sh, but can be csh ou ksh.&lt;BR /&gt;Thanx in advance.</description>
    <pubDate>Wed, 13 Nov 2002 15:40:03 GMT</pubDate>
    <dc:creator>Vogra</dc:creator>
    <dc:date>2002-11-13T15:40:03Z</dc:date>
    <item>
      <title>script shell</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-shell/m-p/2844011#M721300</link>
      <description>Hi All!&lt;BR /&gt; help me please,&lt;BR /&gt; I get the script that list contents of dir, but I need to limit by number of files.&lt;BR /&gt;In other words: &lt;BR /&gt;I have 10 files in /ttp,&lt;BR /&gt;I want to move only the last 5 new. I'm using sh, but can be csh ou ksh.&lt;BR /&gt;Thanx in advance.</description>
      <pubDate>Wed, 13 Nov 2002 15:40:03 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-shell/m-p/2844011#M721300</guid>
      <dc:creator>Vogra</dc:creator>
      <dc:date>2002-11-13T15:40:03Z</dc:date>
    </item>
    <item>
      <title>Re: script shell</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-shell/m-p/2844012#M721301</link>
      <description>ls | tail -n -5&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Wed, 13 Nov 2002 15:53:07 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-shell/m-p/2844012#M721301</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2002-11-13T15:53:07Z</dc:date>
    </item>
    <item>
      <title>Re: script shell</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-shell/m-p/2844013#M721302</link>
      <description>for F in $(ls -rt | tail -5)&lt;BR /&gt;do&lt;BR /&gt; mv $F wherever&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;John</description>
      <pubDate>Wed, 13 Nov 2002 15:54:23 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-shell/m-p/2844013#M721302</guid>
      <dc:creator>John Palmer</dc:creator>
      <dc:date>2002-11-13T15:54:23Z</dc:date>
    </item>
    <item>
      <title>Re: script shell</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-shell/m-p/2844014#M721303</link>
      <description>...and if I don't know the number of files and I want to list all the files less the last 3 files.&lt;BR /&gt;Ex:&lt;BR /&gt;a b c d e f g h&lt;BR /&gt;list only: a b c d e&lt;BR /&gt;f g and h are the new...&lt;BR /&gt;thanx...!</description>
      <pubDate>Wed, 13 Nov 2002 15:54:56 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-shell/m-p/2844014#M721303</guid>
      <dc:creator>Vogra</dc:creator>
      <dc:date>2002-11-13T15:54:56Z</dc:date>
    </item>
    <item>
      <title>Re: script shell</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-shell/m-p/2844015#M721304</link>
      <description>Hi:&lt;BR /&gt;&lt;BR /&gt;Use 'ls -t' to present your list of files sorted by the modification time (latest first) before sorting alphabetically.  Then count off the first five entries and do your processing using only them.&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Wed, 13 Nov 2002 15:55:00 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-shell/m-p/2844015#M721304</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2002-11-13T15:55:00Z</dc:date>
    </item>
    <item>
      <title>Re: script shell</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-shell/m-p/2844016#M721305</link>
      <description>You can use "ls -t" to sort the listing by modified time (latest first) and if you want the lastest 5 just pipe it to "head -5". Something like this ..&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt;&lt;BR /&gt;for file in $(ls -t /ttp|head -5)&lt;BR /&gt;do&lt;BR /&gt;  # do your move here&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;I'm assuming in /ttp there are only files, no directories.&lt;BR /&gt;</description>
      <pubDate>Wed, 13 Nov 2002 15:56:43 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-shell/m-p/2844016#M721305</guid>
      <dc:creator>S.K. Chan</dc:creator>
      <dc:date>2002-11-13T15:56:43Z</dc:date>
    </item>
    <item>
      <title>Re: script shell</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-shell/m-p/2844017#M721306</link>
      <description>Hi All!&lt;BR /&gt;&lt;BR /&gt; the last script is:&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt;NR=`ls /dir1/*.fff|wc -l` # total&lt;BR /&gt;LI=5  # don't touch this&lt;BR /&gt;MV=`expr $NR - $LI`&lt;BR /&gt;VS=/dir1&lt;BR /&gt;VS2=/dir2&lt;BR /&gt;export VS VS2 NR LI MV&lt;BR /&gt;echo $NR, $LI, $MV&lt;BR /&gt;if [ "$NR" -gt "$LI" ]  # &amp;gt; LI files ?&lt;BR /&gt; then&lt;BR /&gt;   for file in $(ls -rt $VS/*.fff|head -$MV)&lt;BR /&gt;    do&lt;BR /&gt;     mv $file $VS2&lt;BR /&gt;    done&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;Thanx to everyone.&lt;BR /&gt;Lima.</description>
      <pubDate>Thu, 14 Nov 2002 10:10:53 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-shell/m-p/2844017#M721306</guid>
      <dc:creator>Vogra</dc:creator>
      <dc:date>2002-11-14T10:10:53Z</dc:date>
    </item>
  </channel>
</rss>

