<?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: script .. in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/script/m-p/4561530#M371735</link>
    <description>Hi:&lt;BR /&gt;&lt;BR /&gt;Your use of the '-t' option with 'ls' suggests that you might want to remove files older than some date/time.  Look at the manpages for 'find'.  You might want to do something like:&lt;BR /&gt;&lt;BR /&gt;# find /path_to_files -type f -mtime +30 -exec rm {} +&lt;BR /&gt;&lt;BR /&gt;...which will remove files that are older than 30-days since their last modification.&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
    <pubDate>Sun, 10 Jan 2010 15:40:17 GMT</pubDate>
    <dc:creator>James R. Ferguson</dc:creator>
    <dc:date>2010-01-10T15:40:17Z</dc:date>
    <item>
      <title>script ..</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script/m-p/4561528#M371733</link>
      <description>Hello Guru,&lt;BR /&gt;&lt;BR /&gt;I am in need of a scripts which is for removing the files that get from the out put of ls -ltr . There are many files and we should not use for loop also. I am requesting this for our dba.&lt;BR /&gt;&lt;BR /&gt;Can any one help me here...&lt;BR /&gt;</description>
      <pubDate>Sun, 10 Jan 2010 14:17:12 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script/m-p/4561528#M371733</guid>
      <dc:creator>UnixT</dc:creator>
      <dc:date>2010-01-10T14:17:12Z</dc:date>
    </item>
    <item>
      <title>Re: script ..</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script/m-p/4561529#M371734</link>
      <description>Hi&lt;BR /&gt;&lt;BR /&gt;cd /dir&lt;BR /&gt;find . 'test' -exec rm {} \;&lt;BR /&gt;&lt;BR /&gt;Regarding 'test':  Need more information.  If you read the man page on find you'll see many 'tests', based upon age, ownerships, etc.&lt;BR /&gt;&lt;BR /&gt;Provide and I'll reciprocate.</description>
      <pubDate>Sun, 10 Jan 2010 15:20:41 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script/m-p/4561529#M371734</guid>
      <dc:creator>Michael Steele_2</dc:creator>
      <dc:date>2010-01-10T15:20:41Z</dc:date>
    </item>
    <item>
      <title>Re: script ..</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script/m-p/4561530#M371735</link>
      <description>Hi:&lt;BR /&gt;&lt;BR /&gt;Your use of the '-t' option with 'ls' suggests that you might want to remove files older than some date/time.  Look at the manpages for 'find'.  You might want to do something like:&lt;BR /&gt;&lt;BR /&gt;# find /path_to_files -type f -mtime +30 -exec rm {} +&lt;BR /&gt;&lt;BR /&gt;...which will remove files that are older than 30-days since their last modification.&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Sun, 10 Jan 2010 15:40:17 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script/m-p/4561530#M371735</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2010-01-10T15:40:17Z</dc:date>
    </item>
    <item>
      <title>Re: script ..</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script/m-p/4561531#M371736</link>
      <description>Hello,&lt;BR /&gt;&lt;BR /&gt;My necessity is something different,....I will give u a scenario as below..&lt;BR /&gt;&lt;BR /&gt;#ls -ltr&lt;BR /&gt;&lt;BR /&gt;a&lt;BR /&gt;b&lt;BR /&gt;c&lt;BR /&gt;d&lt;BR /&gt;e&lt;BR /&gt;f&lt;BR /&gt;g&lt;BR /&gt;&lt;BR /&gt;.&lt;BR /&gt;.&lt;BR /&gt;.&lt;BR /&gt;.&lt;BR /&gt;etc...&lt;BR /&gt;&lt;BR /&gt;and I would like to remove the first few files(say for example as 4 files a,b,c,d). I feel it is enough to get you. In this , no ownership or aging comes in.</description>
      <pubDate>Sun, 10 Jan 2010 19:27:59 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script/m-p/4561531#M371736</guid>
      <dc:creator>UnixT</dc:creator>
      <dc:date>2010-01-10T19:27:59Z</dc:date>
    </item>
    <item>
      <title>Re: script ..</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script/m-p/4561532#M371737</link>
      <description>Hi (again):&lt;BR /&gt;&lt;BR /&gt;&amp;gt; and I would like to remove the first few files(say for example as 4 files a,b,c,d). I feel it is enough to get you. In this , no ownership or aging comes in.&lt;BR /&gt;&lt;BR /&gt;OK, then you could do:&lt;BR /&gt;&lt;BR /&gt;# cd /somepath &amp;amp;&amp;amp; ls -t|head -4|xargs rm&lt;BR /&gt;&lt;BR /&gt;This changes to the directory you want to be in and if successful removes the first four (4) files (most recently modified, first).  If you want to remove the oldest files, do:&lt;BR /&gt;&lt;BR /&gt;# cd /somepath &amp;amp;&amp;amp; ls -rt|head -4|xargs rm&lt;BR /&gt;&lt;BR /&gt;It is assumed that only files and no subdirectories are present.&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...&lt;BR /&gt;</description>
      <pubDate>Sun, 10 Jan 2010 19:57:57 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script/m-p/4561532#M371737</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2010-01-10T19:57:57Z</dc:date>
    </item>
    <item>
      <title>Re: script ..</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script/m-p/4561533#M371738</link>
      <description>Hello UnixT,&lt;BR /&gt;&lt;BR /&gt;You can use this:&lt;BR /&gt;&lt;BR /&gt;--------------------&lt;BR /&gt;for I in `ls -lt | tail -4 | awk '{ print $9 }'`&lt;BR /&gt;do&lt;BR /&gt;rm -i $I&lt;BR /&gt;done&lt;BR /&gt;--------------------&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;rm -i &amp;lt;-- for interactive removal</description>
      <pubDate>Mon, 11 Jan 2010 02:45:59 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script/m-p/4561533#M371738</guid>
      <dc:creator>R.K. #</dc:creator>
      <dc:date>2010-01-11T02:45:59Z</dc:date>
    </item>
    <item>
      <title>Re: script ..</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script/m-p/4561534#M371739</link>
      <description>@R.K&lt;BR /&gt;&lt;BR /&gt;I am not supposed to use for loop here..&lt;BR /&gt;&lt;BR /&gt;@ James,&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;I will try the same and come back to u.&lt;BR /&gt;&lt;BR /&gt;Thanks</description>
      <pubDate>Mon, 11 Jan 2010 04:54:19 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script/m-p/4561534#M371739</guid>
      <dc:creator>UnixT</dc:creator>
      <dc:date>2010-01-11T04:54:19Z</dc:date>
    </item>
    <item>
      <title>Re: script ..</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script/m-p/4561535#M371740</link>
      <description>&lt;!--!*#--&gt;&amp;gt; I am not supposed to use for loop here..&lt;BR /&gt;&lt;BR /&gt;Why not?  Too easy?&lt;BR /&gt;&lt;BR /&gt;&amp;gt; #ls -ltr&lt;BR /&gt;&amp;gt; [...] In this , no ownership or aging comes&lt;BR /&gt;&amp;gt; in.&lt;BR /&gt;&lt;BR /&gt;What do you mean, "no [...] aging comes in"?&lt;BR /&gt;What do you think that "ls -ltr" does, if not&lt;BR /&gt;list files according to their ages?  At least&lt;BR /&gt;one of us is confused about what you want.</description>
      <pubDate>Mon, 11 Jan 2010 06:21:43 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script/m-p/4561535#M371740</guid>
      <dc:creator>Steven Schweda</dc:creator>
      <dc:date>2010-01-11T06:21:43Z</dc:date>
    </item>
    <item>
      <title>Re: script ..</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script/m-p/4561536#M371741</link>
      <description>Hi Steven,&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;I told about the ages because of the upper thread was saying about it..please go thru that.&lt;BR /&gt;&lt;BR /&gt;Next, why I am not using for loop is because ,my DBA does not allowing me to include the same.&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Mon, 11 Jan 2010 06:26:52 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script/m-p/4561536#M371741</guid>
      <dc:creator>UnixT</dc:creator>
      <dc:date>2010-01-11T06:26:52Z</dc:date>
    </item>
    <item>
      <title>Re: script ..</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script/m-p/4561537#M371742</link>
      <description>&amp;gt;&amp;gt; I am not using for loop is because ,my DBA does not allowing me to include the same.&lt;BR /&gt;&lt;BR /&gt;hmmm I can think of a good reason not to use for loops in this manner, but "my DBA told me not to" isn't it! (Although your DBA may be thinking of the same reason that I am)&lt;BR /&gt;&lt;BR /&gt;Do you not have any curiosity? Don't you want to know _why_ you shouldn't use a for loop? Curiosity is the key to learning!&lt;BR /&gt;&lt;BR /&gt;HTH&lt;BR /&gt;&lt;BR /&gt;Duncan</description>
      <pubDate>Mon, 11 Jan 2010 08:11:11 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script/m-p/4561537#M371742</guid>
      <dc:creator>Duncan Edmonstone</dc:creator>
      <dc:date>2010-01-11T08:11:11Z</dc:date>
    </item>
    <item>
      <title>Re: script ..</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script/m-p/4561538#M371743</link>
      <description>rm $(ls -ltr | awk 'NR &amp;lt;= 4 { print $9 }')&lt;BR /&gt;&lt;BR /&gt;&amp;gt;Duncan: I can think of a good reason not to use for loops in this manner&lt;BR /&gt;&lt;BR /&gt;Because 4 is too small to bother?  :-)</description>
      <pubDate>Mon, 11 Jan 2010 11:35:06 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script/m-p/4561538#M371743</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2010-01-11T11:35:06Z</dc:date>
    </item>
    <item>
      <title>Re: script ..</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script/m-p/4561539#M371744</link>
      <description>&amp;gt;Because 4 is too small to bother? :-)&lt;BR /&gt;&lt;BR /&gt;no actually because what if the filenames are _really_ long (or we have a lot more than 4 files - not valid for this example but a generic reason to avoid for loops) - we can run into the problem of exceeding the max line length or argument count for the shell.&lt;BR /&gt;&lt;BR /&gt;instead of:&lt;BR /&gt;&lt;BR /&gt;for x in &lt;LIST&gt;&lt;BR /&gt;do&lt;BR /&gt; ...&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;I would always do:&lt;BR /&gt;&lt;BR /&gt;cat &lt;LIST&gt; | while read x&lt;BR /&gt;do&lt;BR /&gt; ...&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;(syntactically incorrect, but you get the gist) &lt;BR /&gt;that lesson learnt after debugging a script which deleted archive logs in a directory - it stopped working when there we more than 255 logs present...&lt;BR /&gt;&lt;BR /&gt;Duncan&lt;/LIST&gt;&lt;/LIST&gt;</description>
      <pubDate>Mon, 11 Jan 2010 12:51:52 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script/m-p/4561539#M371744</guid>
      <dc:creator>Duncan Edmonstone</dc:creator>
      <dc:date>2010-01-11T12:51:52Z</dc:date>
    </item>
    <item>
      <title>Re: script ..</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script/m-p/4561540#M371745</link>
      <description>&amp;gt;Duncan: actually because what if the filenames are _really_ long (or we have a lot more than 4 files...) we can run into the problem of exceeding the max line length or argument count for the shell.&lt;BR /&gt;&lt;BR /&gt;In both cases, you can't use a for-loop nor my $().  Typically 4 * N will always be less than 2 Mb.&lt;BR /&gt;&lt;BR /&gt;&amp;gt;I would always do: while read x&lt;BR /&gt;&amp;gt;(syntactically incorrect&lt;BR /&gt;&lt;BR /&gt;You mean evil cat incorrect.  :-)&lt;BR /&gt;&lt;BR /&gt;Yes, while read or xargs.</description>
      <pubDate>Tue, 12 Jan 2010 04:50:08 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script/m-p/4561540#M371745</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2010-01-12T04:50:08Z</dc:date>
    </item>
  </channel>
</rss>

