<?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: How to modify this simple script??? in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/how-to-modify-this-simple-script/m-p/2439017#M6540</link>
    <description>Thanks Jaroslaw,&lt;BR /&gt;&lt;BR /&gt;Your solution works great as well!!! If you get a chance can you explain the following line for me:&lt;BR /&gt;&lt;BR /&gt;rm $(ls -1t | awk 'NR&amp;gt;100')&lt;BR /&gt;&lt;BR /&gt;I not sure what awk or NR do... My understanding of scripting needs to get better...&lt;BR /&gt;&lt;BR /&gt;Thanks &lt;BR /&gt;Shaun Aldrich</description>
    <pubDate>Wed, 23 Aug 2000 13:29:39 GMT</pubDate>
    <dc:creator>Shaun Aldrich</dc:creator>
    <dc:date>2000-08-23T13:29:39Z</dc:date>
    <item>
      <title>How to modify this simple script???</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/how-to-modify-this-simple-script/m-p/2439000#M6523</link>
      <description>Hello everyone,&lt;BR /&gt;&lt;BR /&gt;Currently I have a directory called /home/shaun/boristest. This contains database files which continually grows. There are approximately 200 plus files in it. As a regular maintnance I have been told by the DBA that he only wants to keep the latest 100 files according to timestamp. The below script3 currently removes 100 files. So if there is 300 files then it will remove 100 and there will still be the latest 200. This is close to being correct but does anyone know how I could modify this simple script to only leave the latest 100 and no more. Your help is greatly appreciated... &lt;BR /&gt;&lt;BR /&gt;drwxrwxrwx   2 shaun      adm           4096 Aug 23 08:42 boristest&lt;BR /&gt;-rwxrwxr-x   1 shaun      adm            263 Aug 22 09:22 script1&lt;BR /&gt;-rwxrwxr-x   1 shaun      adm             84 Aug 22 09:21 script2&lt;BR /&gt;-rwxrwxr-x   1 shaun      adm             63 Aug 23 08:41 script3&lt;BR /&gt;-rwxrwxrwx   1 shaun      adm             87 Aug 22 09:26 test2&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt;&lt;BR /&gt;cd /home/shaun/boristest&lt;BR /&gt;rm `ls -t | tail -100`&lt;BR /&gt;&lt;BR /&gt;Thanks &lt;BR /&gt;Shaun Aldrich&lt;BR /&gt;SAldrich@chaptersinc.com</description>
      <pubDate>Wed, 23 Aug 2000 11:59:14 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/how-to-modify-this-simple-script/m-p/2439000#M6523</guid>
      <dc:creator>Shaun Aldrich</dc:creator>
      <dc:date>2000-08-23T11:59:14Z</dc:date>
    </item>
    <item>
      <title>Re: How to modify this simple script???</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/how-to-modify-this-simple-script/m-p/2439001#M6524</link>
      <description>man tail ;) should to the trick !</description>
      <pubDate>Wed, 23 Aug 2000 12:02:01 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/how-to-modify-this-simple-script/m-p/2439001#M6524</guid>
      <dc:creator>Alex Glennie</dc:creator>
      <dc:date>2000-08-23T12:02:01Z</dc:date>
    </item>
    <item>
      <title>Re: How to modify this simple script???</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/how-to-modify-this-simple-script/m-p/2439002#M6525</link>
      <description>or try 200 ?</description>
      <pubDate>Wed, 23 Aug 2000 12:02:48 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/how-to-modify-this-simple-script/m-p/2439002#M6525</guid>
      <dc:creator>Alex Glennie</dc:creator>
      <dc:date>2000-08-23T12:02:48Z</dc:date>
    </item>
    <item>
      <title>Re: How to modify this simple script???</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/how-to-modify-this-simple-script/m-p/2439003#M6526</link>
      <description>You have the solution:&lt;BR /&gt;In a previous mail you sent.&lt;BR /&gt;Tom's rm `ls -1t | tail +101`&lt;BR /&gt;and my rm `ls |grep -v "$(ls -t|head -n100)"`&lt;BR /&gt;&lt;BR /&gt;But didnt pay...</description>
      <pubDate>Wed, 23 Aug 2000 12:06:33 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/how-to-modify-this-simple-script/m-p/2439003#M6526</guid>
      <dc:creator>Victor BERRIDGE</dc:creator>
      <dc:date>2000-08-23T12:06:33Z</dc:date>
    </item>
    <item>
      <title>Re: How to modify this simple script???</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/how-to-modify-this-simple-script/m-p/2439004#M6527</link>
      <description>Hi Victor/Tom,&lt;BR /&gt;&lt;BR /&gt;Thanks a lot for your reply... I couldn't get either of these to work. Here is a copy of your script Victor which I called script2 and the results when I ran it.&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt;&lt;BR /&gt;cd /home/shaun/boristest&lt;BR /&gt;for FILE in 'ls | grep -v "$(ls -t | head -n100)"'&lt;BR /&gt;do&lt;BR /&gt;rm $FILE&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;$ ./script2&lt;BR /&gt;rm: ls non-existent&lt;BR /&gt;rm: | non-existent&lt;BR /&gt;rm: -v non-existent&lt;BR /&gt;rm: "$(ls non-existent&lt;BR /&gt;rm: -t non-existent&lt;BR /&gt;rm: | non-existent&lt;BR /&gt;rm: head non-existent&lt;BR /&gt;rm: -n100)" non-existent&lt;BR /&gt;&lt;BR /&gt;Any help is greatly appreciated...&lt;BR /&gt;&lt;BR /&gt;Shaun Aldrich&lt;BR /&gt;</description>
      <pubDate>Wed, 23 Aug 2000 12:13:19 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/how-to-modify-this-simple-script/m-p/2439004#M6527</guid>
      <dc:creator>Shaun Aldrich</dc:creator>
      <dc:date>2000-08-23T12:13:19Z</dc:date>
    </item>
    <item>
      <title>Re: How to modify this simple script???</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/how-to-modify-this-simple-script/m-p/2439005#M6528</link>
      <description>I guess your next question:&lt;BR /&gt;What difference between the 2.&lt;BR /&gt;tom: i rm after sorting by time after the 100 first&lt;BR /&gt;Victor: i rm all except the result of grep -v&lt;BR /&gt;&lt;BR /&gt;I know my english is hopeless, but I try my best&lt;BR /&gt;&lt;BR /&gt;Victor</description>
      <pubDate>Wed, 23 Aug 2000 12:13:41 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/how-to-modify-this-simple-script/m-p/2439005#M6528</guid>
      <dc:creator>Victor BERRIDGE</dc:creator>
      <dc:date>2000-08-23T12:13:41Z</dc:date>
    </item>
    <item>
      <title>Re: How to modify this simple script???</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/how-to-modify-this-simple-script/m-p/2439006#M6529</link>
      <description>Hi Victor,&lt;BR /&gt;&lt;BR /&gt;Either script would be good for me if I could get them to work... Thanks for your continous replies...&lt;BR /&gt;&lt;BR /&gt;Shaun Aldrich</description>
      <pubDate>Wed, 23 Aug 2000 12:16:11 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/how-to-modify-this-simple-script/m-p/2439006#M6529</guid>
      <dc:creator>Shaun Aldrich</dc:creator>
      <dc:date>2000-08-23T12:16:11Z</dc:date>
    </item>
    <item>
      <title>Re: How to modify this simple script???</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/how-to-modify-this-simple-script/m-p/2439007#M6530</link>
      <description>Hi Shaun,&lt;BR /&gt;You quotes go the wong way I dont know how you call them, you put '&lt;BR /&gt;It should be `&lt;BR /&gt;(Im in a french speaking world...)&lt;BR /&gt;Regards&lt;BR /&gt;Victor</description>
      <pubDate>Wed, 23 Aug 2000 12:16:46 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/how-to-modify-this-simple-script/m-p/2439007#M6530</guid>
      <dc:creator>Victor BERRIDGE</dc:creator>
      <dc:date>2000-08-23T12:16:46Z</dc:date>
    </item>
    <item>
      <title>Re: How to modify this simple script???</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/how-to-modify-this-simple-script/m-p/2439008#M6531</link>
      <description>Dear Shaun&lt;BR /&gt;&lt;BR /&gt;I'd suggest to modify your script as follows&lt;BR /&gt;&lt;BR /&gt;rm $(ls -1t | awk 'NR&amp;gt;100')&lt;BR /&gt;&lt;BR /&gt;regards&lt;BR /&gt;&lt;BR /&gt;Jaroslaw</description>
      <pubDate>Wed, 23 Aug 2000 12:17:48 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/how-to-modify-this-simple-script/m-p/2439008#M6531</guid>
      <dc:creator>Jaroslaw Tomkiewicz</dc:creator>
      <dc:date>2000-08-23T12:17:48Z</dc:date>
    </item>
    <item>
      <title>Re: How to modify this simple script???</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/how-to-modify-this-simple-script/m-p/2439009#M6532</link>
      <description>Thanks a lot Victor your script works!!!! I obviously need a class in scripting. Especially since a lot of the work I do is with NNM and IT/Operations...&lt;BR /&gt;&lt;BR /&gt;Thanks again for all of the replies...&lt;BR /&gt;&lt;BR /&gt;Shaun Aldrich&lt;BR /&gt;SAldrich@chaptersinc.com</description>
      <pubDate>Wed, 23 Aug 2000 12:29:06 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/how-to-modify-this-simple-script/m-p/2439009#M6532</guid>
      <dc:creator>Shaun Aldrich</dc:creator>
      <dc:date>2000-08-23T12:29:06Z</dc:date>
    </item>
    <item>
      <title>Re: How to modify this simple script???</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/how-to-modify-this-simple-script/m-p/2439010#M6533</link>
      <description>cd /home/shaun/boristest&lt;BR /&gt;then do find . -name * -exec +100 ls -latr {} \;&lt;BR /&gt;</description>
      <pubDate>Wed, 23 Aug 2000 12:31:09 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/how-to-modify-this-simple-script/m-p/2439010#M6533</guid>
      <dc:creator>CHRIS_ANORUO</dc:creator>
      <dc:date>2000-08-23T12:31:09Z</dc:date>
    </item>
    <item>
      <title>Re: How to modify this simple script???</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/how-to-modify-this-simple-script/m-p/2439011#M6534</link>
      <description>Hi Jaroslaw,&lt;BR /&gt;&lt;BR /&gt;I thought I would try the suggestion that you gave as well and here are the results:&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt;&lt;BR /&gt;cd /home/shaun/boristest&lt;BR /&gt;rm $(ls -1t | awk `NR&amp;gt;100`)&lt;BR /&gt;&lt;BR /&gt;$ ./script4&lt;BR /&gt;./script4[4]: NR:  not found.&lt;BR /&gt;Usage: awk [-F fs][-v Assignment][-f Progfile|Program][Assignment|File] ...&lt;BR /&gt;Usage: rm [-Rfir] file ...&lt;BR /&gt;&lt;BR /&gt;Any suggestions on why this failed...&lt;BR /&gt;&lt;BR /&gt;Thanks&lt;BR /&gt;Shaun Aldrich</description>
      <pubDate>Wed, 23 Aug 2000 12:41:59 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/how-to-modify-this-simple-script/m-p/2439011#M6534</guid>
      <dc:creator>Shaun Aldrich</dc:creator>
      <dc:date>2000-08-23T12:41:59Z</dc:date>
    </item>
    <item>
      <title>Re: How to modify this simple script???</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/how-to-modify-this-simple-script/m-p/2439012#M6535</link>
      <description>Dear Shaun&lt;BR /&gt;&lt;BR /&gt;I suppose that there is the same mistake as previous. &lt;BR /&gt;You should use ' instead of `&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Regards&lt;BR /&gt;&lt;BR /&gt;Jaroslaw&lt;BR /&gt;&lt;BR /&gt;Jaroslaw</description>
      <pubDate>Wed, 23 Aug 2000 12:52:34 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/how-to-modify-this-simple-script/m-p/2439012#M6535</guid>
      <dc:creator>Jaroslaw Tomkiewicz</dc:creator>
      <dc:date>2000-08-23T12:52:34Z</dc:date>
    </item>
    <item>
      <title>Re: How to modify this simple script???</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/how-to-modify-this-simple-script/m-p/2439013#M6536</link>
      <description>Hi Chris,&lt;BR /&gt;&lt;BR /&gt;Thanks for your replies to my questions on the forum. I am going to assign points for you right now. Below is the results from what I just tried after your suggestion:&lt;BR /&gt; &lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt; &lt;BR /&gt;cd /home/shaun/boristest&lt;BR /&gt;find . -name * -exec +100 ls -latr {}&lt;BR /&gt; &lt;BR /&gt;$ ./script5&lt;BR /&gt;find: missing conjunction&lt;BR /&gt;&lt;BR /&gt;Do you know what it means by missing conjunction? Thanks for your help. &lt;BR /&gt; &lt;BR /&gt;Shaun Aldrich</description>
      <pubDate>Wed, 23 Aug 2000 12:53:26 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/how-to-modify-this-simple-script/m-p/2439013#M6536</guid>
      <dc:creator>Shaun Aldrich</dc:creator>
      <dc:date>2000-08-23T12:53:26Z</dc:date>
    </item>
    <item>
      <title>Re: How to modify this simple script???</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/how-to-modify-this-simple-script/m-p/2439014#M6537</link>
      <description>Hi Jaroslaw,&lt;BR /&gt;&lt;BR /&gt;I did use the proper quotes that you recommended. Any other ideas?&lt;BR /&gt;&lt;BR /&gt;Thanks&lt;BR /&gt;&lt;BR /&gt;Shaun Aldrich</description>
      <pubDate>Wed, 23 Aug 2000 12:55:42 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/how-to-modify-this-simple-script/m-p/2439014#M6537</guid>
      <dc:creator>Shaun Aldrich</dc:creator>
      <dc:date>2000-08-23T12:55:42Z</dc:date>
    </item>
    <item>
      <title>Re: How to modify this simple script???</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/how-to-modify-this-simple-script/m-p/2439015#M6538</link>
      <description>Dear Shaun&lt;BR /&gt;&lt;BR /&gt;If I use single quotation mark my command works properly.&lt;BR /&gt;&lt;BR /&gt;[/tmp/jt]# rm $(ls -1t | awk 'NR&amp;gt;1')    &lt;BR /&gt;[/tmp/jt]# ls                       &lt;BR /&gt;kas.sh&lt;BR /&gt;[/tmp/jt]#&lt;BR /&gt;&lt;BR /&gt;Problem arised when I replaced single quotation mark with apostrophe sign:&lt;BR /&gt;&lt;BR /&gt;[/tmp/jt]# rm $(ls -1t | awk `NR&amp;gt;1`) &lt;BR /&gt;sh: NR:  not found.&lt;BR /&gt;Usage: awk [-F fs][-v Assignment][-f Progfile|Program][Assignment|File] ...&lt;BR /&gt;Usage: rm [-Rfir] file ...&lt;BR /&gt;&lt;BR /&gt;Regards&lt;BR /&gt;&lt;BR /&gt;Jaroslaw</description>
      <pubDate>Wed, 23 Aug 2000 13:10:20 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/how-to-modify-this-simple-script/m-p/2439015#M6538</guid>
      <dc:creator>Jaroslaw Tomkiewicz</dc:creator>
      <dc:date>2000-08-23T13:10:20Z</dc:date>
    </item>
    <item>
      <title>Re: How to modify this simple script???</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/how-to-modify-this-simple-script/m-p/2439016#M6539</link>
      <description>I would use:&lt;BR /&gt;&lt;BR /&gt;cd /home/shaun/boristest &amp;amp;&amp;amp;&lt;BR /&gt;ls -1t *.dbf | tail +101 | xargs rm&lt;BR /&gt;&lt;BR /&gt;The &amp;amp;&amp;amp; after the cd means "run the following command only if the cd succeeds" - this script will eventually end up as a cron-job, maybe run by root - if anybody ever moves or removes /home/shaun/boristest the cd will fail, but whithout the &amp;amp;&amp;amp; rm will do its job on other files it finds in the current directory  - you do not want that to happen - trust me!&lt;BR /&gt;&lt;BR /&gt;The *.dbf is an example only, be just as specific as possible with the names of the files you want to delete - again just as a precaution. &lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Wed, 23 Aug 2000 13:11:48 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/how-to-modify-this-simple-script/m-p/2439016#M6539</guid>
      <dc:creator>Peter Scheer</dc:creator>
      <dc:date>2000-08-23T13:11:48Z</dc:date>
    </item>
    <item>
      <title>Re: How to modify this simple script???</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/how-to-modify-this-simple-script/m-p/2439017#M6540</link>
      <description>Thanks Jaroslaw,&lt;BR /&gt;&lt;BR /&gt;Your solution works great as well!!! If you get a chance can you explain the following line for me:&lt;BR /&gt;&lt;BR /&gt;rm $(ls -1t | awk 'NR&amp;gt;100')&lt;BR /&gt;&lt;BR /&gt;I not sure what awk or NR do... My understanding of scripting needs to get better...&lt;BR /&gt;&lt;BR /&gt;Thanks &lt;BR /&gt;Shaun Aldrich</description>
      <pubDate>Wed, 23 Aug 2000 13:29:39 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/how-to-modify-this-simple-script/m-p/2439017#M6540</guid>
      <dc:creator>Shaun Aldrich</dc:creator>
      <dc:date>2000-08-23T13:29:39Z</dc:date>
    </item>
    <item>
      <title>Re: How to modify this simple script???</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/how-to-modify-this-simple-script/m-p/2439018#M6541</link>
      <description>Dear Shaun&lt;BR /&gt;&lt;BR /&gt;According to HP-UX description awk is a "&lt;BR /&gt;- pattern-directed scanning and processing language". You can get many details running man awk command.&lt;BR /&gt;&lt;BR /&gt;NR is a special variable which means Number of Records. &lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;regards&lt;BR /&gt;&lt;BR /&gt;Jaroslaw</description>
      <pubDate>Wed, 23 Aug 2000 13:40:01 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/how-to-modify-this-simple-script/m-p/2439018#M6541</guid>
      <dc:creator>Jaroslaw Tomkiewicz</dc:creator>
      <dc:date>2000-08-23T13:40:01Z</dc:date>
    </item>
    <item>
      <title>Re: How to modify this simple script???</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/how-to-modify-this-simple-script/m-p/2439019#M6542</link>
      <description>The attached should be of help.&lt;BR /&gt;&lt;BR /&gt;Cheers!&lt;BR /&gt;</description>
      <pubDate>Wed, 23 Aug 2000 14:30:39 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/how-to-modify-this-simple-script/m-p/2439019#M6542</guid>
      <dc:creator>CHRIS_ANORUO</dc:creator>
      <dc:date>2000-08-23T14:30:39Z</dc:date>
    </item>
  </channel>
</rss>

