<?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: Finding and deleting sub-directories by date in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/finding-and-deleting-sub-directories-by-date/m-p/6802208#M494737</link>
    <description>&lt;P&gt;Hello everyone,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for your reply.&amp;nbsp; Let me see if I can clear up the water just a bit....&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Various directories exist on the system for archiving information.&amp;nbsp; Though they all have the same name, they may reside at different layers&amp;nbsp; within each filesystem.&amp;nbsp; These all have the same name (I used DIR before).&amp;nbsp; So on the system, we have something like this....&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;/alpha/subdir/subdir/DIR&lt;/P&gt;&lt;P&gt;/bravo/subdir/DIR&lt;/P&gt;&lt;P&gt;/charlie/subdir/subdir/subdir/subdir/DIR&lt;/P&gt;&lt;P&gt;/charlie/subdir/subdir/DIR&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Underneath each DIR, archive information is written.&amp;nbsp; These are created as subdirectories under DIR, so you may have something like this....&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;/alpha/subdir/subdir/DIR/archive-directory-from-today&lt;/P&gt;&lt;P&gt;/alpha/subdir/subdir/DIR/archive-directory-from-yesterday&lt;/P&gt;&lt;P&gt;/alpha/subdir/subdir/DIR/archive-directory-from-a-day-last-week&lt;/P&gt;&lt;P&gt;/bravo/subdir/DIR/archive-directory-from-a-day-last-month&lt;/P&gt;&lt;P&gt;...etc&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Although all of the DIR directories have a consistent name, the subdirectories under them can be named various things.&amp;nbsp; The goal is to delete all of the subdirectories under each DIR that are older than a certain number of days.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The current method is to find all the instances of DIR and create a temp file.&amp;nbsp; Then it is using a while/do/done loop to go through the list of directories in the temp file, cd into them, and then do a "find . -mtime +95 -print -exec rm -r + " for example.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What I am needing to do is purge the subdirectories under the DIR directories without deleting the DIR directories.&amp;nbsp; What I am finding is that the rm statement will attempt to delete DIR if it meets the parameters for the -mtime.&amp;nbsp; If I cd into the DIR directory prior to the rm statement, it will not delete the DIR directory (since it is in it), but I will get a rm error saying it could not delete it&amp;nbsp; (rm:&amp;nbsp; cannot remove .. or . )&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is an old script that was written a long time ago that needs to be cleaned up.&amp;nbsp; My goal is I would like to make it not have to cd into the directory and get the occassional rm error back.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you, everyone, for your help.&lt;/P&gt;</description>
    <pubDate>Wed, 14 Oct 2015 12:30:33 GMT</pubDate>
    <dc:creator>TheJuiceman</dc:creator>
    <dc:date>2015-10-14T12:30:33Z</dc:date>
    <item>
      <title>Finding and deleting sub-directories by date</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/finding-and-deleting-sub-directories-by-date/m-p/6802021#M494733</link>
      <description>&lt;P&gt;I am needing to do a find command and look for all instances of a directory called DIR.&amp;nbsp; I then want to delete any sub-directories in the found DIR directories older than a month.&amp;nbsp; Some of the DIR directories may not have any sub-directories in them.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How can I construct a find/rm&amp;nbsp;script to successfully find these older subdirectories and remove them without trying to delete the parent (ie. "rm -r ." or "rm -r ..").&amp;nbsp; Some of the parent DIR directories may also be older than a month, but I do not want to delete the DIR directory.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;There does not seem to be a maxdepth and mindepth equivalent available.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there a "clean" way to do this without getting the occasional error or having to cd into the parent DIR to prevent accidental deletion?&amp;nbsp; Thanks&lt;/P&gt;</description>
      <pubDate>Tue, 13 Oct 2015 21:23:34 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/finding-and-deleting-sub-directories-by-date/m-p/6802021#M494733</guid>
      <dc:creator>TheJuiceman</dc:creator>
      <dc:date>2015-10-13T21:23:34Z</dc:date>
    </item>
    <item>
      <title>Re: Finding and deleting sub-directories by date</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/finding-and-deleting-sub-directories-by-date/m-p/6802064#M494735</link>
      <description>&lt;P&gt;&amp;gt; [...] I then want to delete any sub-directories in the found DIR&lt;BR /&gt;&amp;gt; directories older than a month. [...]&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; Do you want to delete only old subdirectories in DIR itself&lt;BR /&gt;("DIR/fred"), or all old subdirectories anywhere under DIR ("DIR/fred",&lt;BR /&gt;"DIR/a/fred", "DIR/a/b/fred", ...)?&lt;BR /&gt;&lt;BR /&gt;&amp;gt; How can I construct a find/rm script to successfully find these older&lt;BR /&gt;&amp;gt; subdirectories and remove them without trying to delete the parent&lt;BR /&gt;&amp;gt; (ie. "rm -r ." or "rm -r ..").&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; I'm confused.&amp;nbsp; When you identify an old subdirectory, then you should&lt;BR /&gt;be able to delete that subdirectory ("rm -r path/to/subdir").&amp;nbsp; Where's&lt;BR /&gt;the risk of deleting its parent?&lt;BR /&gt;&lt;BR /&gt;&amp;gt; There does not seem to be a maxdepth and mindepth equivalent&lt;BR /&gt;&amp;gt; available.&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; I assume that you're running some version of HP-UX, and that its&lt;BR /&gt;"find" lacks some of the features of GNU "find".&amp;nbsp; If you really want the&lt;BR /&gt;features of GNU "find", then why not install (and use) GNU "find"?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;gt; Is there a "clean" way to do this without getting the occasional error&lt;BR /&gt;&amp;gt; or having to cd into the parent DIR to prevent accidental deletion?&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; What kind of "occasional error" do you expect (or see)?&amp;nbsp; What's the&lt;BR /&gt;problem with doing a "cd path/to/DIR" (if it might be helpful)?&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; I might do this in two pieces.&amp;nbsp; First, a "find" command to identify&lt;BR /&gt;all the "DIR" directories.&amp;nbsp; Perhaps something like:&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; find dir -type d -name DIR -exec script2.sh {} \;&lt;BR /&gt;&lt;BR /&gt;And then have script2.sh look for old subdirectories (in its "$1"&lt;BR /&gt;directory), and do whatever you want done with them (probably using&lt;BR /&gt;another "find [...] -exec [...]" command.&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; It's difficult to debug a script (or set of scripts) which exists&lt;BR /&gt;only in your head.&amp;nbsp; Write something, and _then_ complain about how it&lt;BR /&gt;works.&amp;nbsp; While experimenting, I'd replace (or prefix) all "rm" commands&lt;BR /&gt;with "echo" commands, so that you can see what the script(s) would do,&lt;BR /&gt;with less risk of permanent damage.&lt;/P&gt;</description>
      <pubDate>Wed, 14 Oct 2015 03:47:41 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/finding-and-deleting-sub-directories-by-date/m-p/6802064#M494735</guid>
      <dc:creator>Steven Schweda</dc:creator>
      <dc:date>2015-10-14T03:47:41Z</dc:date>
    </item>
    <item>
      <title>Re: Finding and deleting sub-directories by date</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/finding-and-deleting-sub-directories-by-date/m-p/6802136#M494736</link>
      <description>&lt;P&gt;&amp;gt;sub-directories in the found DIR directories older than a month.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You don't care how new the files in that directory are?&lt;/P&gt;&lt;P&gt;Or are the files written only once and that's enough to set the modify time on the directory?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;gt;Some of the parent DIR directories may also be older than a month, but I do not want to delete DIR.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is where a clever use of -prune will help.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;start with:&lt;/P&gt;&lt;P&gt;find $DIR -type d -mtime +60&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And you have to be careful if multiple levels of subdirectories since the removing will change the date on the parent.&amp;nbsp; -depth may help here.&lt;/P&gt;&lt;P&gt;Did you want to remove all subdirectories even if newer than the intermediate directories?&lt;/P&gt;</description>
      <pubDate>Wed, 14 Oct 2015 08:47:11 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/finding-and-deleting-sub-directories-by-date/m-p/6802136#M494736</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2015-10-14T08:47:11Z</dc:date>
    </item>
    <item>
      <title>Re: Finding and deleting sub-directories by date</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/finding-and-deleting-sub-directories-by-date/m-p/6802208#M494737</link>
      <description>&lt;P&gt;Hello everyone,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for your reply.&amp;nbsp; Let me see if I can clear up the water just a bit....&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Various directories exist on the system for archiving information.&amp;nbsp; Though they all have the same name, they may reside at different layers&amp;nbsp; within each filesystem.&amp;nbsp; These all have the same name (I used DIR before).&amp;nbsp; So on the system, we have something like this....&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;/alpha/subdir/subdir/DIR&lt;/P&gt;&lt;P&gt;/bravo/subdir/DIR&lt;/P&gt;&lt;P&gt;/charlie/subdir/subdir/subdir/subdir/DIR&lt;/P&gt;&lt;P&gt;/charlie/subdir/subdir/DIR&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Underneath each DIR, archive information is written.&amp;nbsp; These are created as subdirectories under DIR, so you may have something like this....&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;/alpha/subdir/subdir/DIR/archive-directory-from-today&lt;/P&gt;&lt;P&gt;/alpha/subdir/subdir/DIR/archive-directory-from-yesterday&lt;/P&gt;&lt;P&gt;/alpha/subdir/subdir/DIR/archive-directory-from-a-day-last-week&lt;/P&gt;&lt;P&gt;/bravo/subdir/DIR/archive-directory-from-a-day-last-month&lt;/P&gt;&lt;P&gt;...etc&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Although all of the DIR directories have a consistent name, the subdirectories under them can be named various things.&amp;nbsp; The goal is to delete all of the subdirectories under each DIR that are older than a certain number of days.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The current method is to find all the instances of DIR and create a temp file.&amp;nbsp; Then it is using a while/do/done loop to go through the list of directories in the temp file, cd into them, and then do a "find . -mtime +95 -print -exec rm -r + " for example.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What I am needing to do is purge the subdirectories under the DIR directories without deleting the DIR directories.&amp;nbsp; What I am finding is that the rm statement will attempt to delete DIR if it meets the parameters for the -mtime.&amp;nbsp; If I cd into the DIR directory prior to the rm statement, it will not delete the DIR directory (since it is in it), but I will get a rm error saying it could not delete it&amp;nbsp; (rm:&amp;nbsp; cannot remove .. or . )&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is an old script that was written a long time ago that needs to be cleaned up.&amp;nbsp; My goal is I would like to make it not have to cd into the directory and get the occassional rm error back.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you, everyone, for your help.&lt;/P&gt;</description>
      <pubDate>Wed, 14 Oct 2015 12:30:33 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/finding-and-deleting-sub-directories-by-date/m-p/6802208#M494737</guid>
      <dc:creator>TheJuiceman</dc:creator>
      <dc:date>2015-10-14T12:30:33Z</dc:date>
    </item>
    <item>
      <title>Re: Finding and deleting sub-directories by date</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/finding-and-deleting-sub-directories-by-date/m-p/6802233#M494738</link>
      <description>&lt;P&gt;&amp;gt; [...] "find . -mtime +95 -print -exec rm -r + "&lt;BR /&gt;&lt;BR /&gt;&amp;gt; If I cd into the DIR directory prior to the rm statement, it will not&lt;BR /&gt;&amp;gt; delete the DIR directory (since it is in it), but I will get a rm&lt;BR /&gt;&amp;gt; error saying it could not delete it&amp;nbsp; (rm:&amp;nbsp; cannot remove .. or . )&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; If "." is the biggest problem, then consider:&lt;BR /&gt;&lt;BR /&gt;mba$&amp;nbsp; find . -exec echo {} \;&lt;BR /&gt;.&lt;BR /&gt;./test2&lt;BR /&gt;./test2/fred&lt;BR /&gt;&lt;BR /&gt;mba$&amp;nbsp; find . '!' -name . -exec echo {} \;&lt;BR /&gt;./test2&lt;BR /&gt;./test2/fred&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; (At least "find" doesn't return "..", too.)&lt;/P&gt;</description>
      <pubDate>Wed, 14 Oct 2015 13:56:59 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/finding-and-deleting-sub-directories-by-date/m-p/6802233#M494738</guid>
      <dc:creator>Steven Schweda</dc:creator>
      <dc:date>2015-10-14T13:56:59Z</dc:date>
    </item>
    <item>
      <title>Re: Finding and deleting sub-directories by date</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/finding-and-deleting-sub-directories-by-date/m-p/6802271#M494739</link>
      <description>&lt;P&gt;&amp;gt; The current method is to find all the instances of DIR and create a&lt;BR /&gt;&amp;gt; temp file.&amp;nbsp; Then it is using a while/do/done loop to go through the&lt;BR /&gt;&amp;gt; list of directories in the temp file, [...]&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; I can't see your script, so I know othing, but I'd probably try to&lt;BR /&gt;avoid such a temporary file.&amp;nbsp; Instead, I'd look for a way to feed the&lt;BR /&gt;results from the DIR search into the second phase.&amp;nbsp; That could be done&lt;BR /&gt;using multiple scripts (as suggested above) or a plain-old pipeline in a&lt;BR /&gt;single script.&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; Writing a bunch of data to a file only to read them back out again is&lt;BR /&gt;often not the best method.&lt;/P&gt;</description>
      <pubDate>Wed, 14 Oct 2015 14:57:38 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/finding-and-deleting-sub-directories-by-date/m-p/6802271#M494739</guid>
      <dc:creator>Steven Schweda</dc:creator>
      <dc:date>2015-10-14T14:57:38Z</dc:date>
    </item>
    <item>
      <title>Re: Finding and deleting sub-directories by date</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/finding-and-deleting-sub-directories-by-date/m-p/6802289#M494740</link>
      <description>&lt;P&gt;find / -type d -name DIR &amp;gt; /tmp/DIR.tmp&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;while read TMP&lt;/P&gt;&lt;P&gt;do&lt;/P&gt;&lt;P&gt;cd $TMP&lt;/P&gt;&lt;P&gt;find . -mtime +95 -print rm -r {} \;&lt;/P&gt;&lt;P&gt;done &amp;lt; /tmp/DIR.tmp&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 14 Oct 2015 15:37:05 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/finding-and-deleting-sub-directories-by-date/m-p/6802289#M494740</guid>
      <dc:creator>TheJuiceman</dc:creator>
      <dc:date>2015-10-14T15:37:05Z</dc:date>
    </item>
    <item>
      <title>Re: Finding and deleting sub-directories by date</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/finding-and-deleting-sub-directories-by-date/m-p/6802335#M494741</link>
      <description>&lt;P&gt;&amp;gt; find / -type d -name DIR &amp;gt; /tmp/DIR.tmp&lt;BR /&gt;&amp;gt;&lt;BR /&gt;&amp;gt; while read TMP&lt;BR /&gt;&amp;gt; do&lt;BR /&gt;&amp;gt; [...]&lt;BR /&gt;&amp;gt; done &amp;lt; /tmp/DIR.tmp&lt;BR /&gt;&lt;BR /&gt;find / -type d -name DIR | \&lt;BR /&gt;(&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; while read TMP ; do&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; [...]&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; done&lt;BR /&gt;)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; Sub-shell parentheses can be very helpful.&lt;/P&gt;</description>
      <pubDate>Wed, 14 Oct 2015 18:04:16 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/finding-and-deleting-sub-directories-by-date/m-p/6802335#M494741</guid>
      <dc:creator>Steven Schweda</dc:creator>
      <dc:date>2015-10-14T18:04:16Z</dc:date>
    </item>
    <item>
      <title>Re: Finding and deleting sub-directories by date</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/finding-and-deleting-sub-directories-by-date/m-p/6802345#M494742</link>
      <description>&lt;P&gt;Hi Steven,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I appreciate your help.&amp;nbsp; That does make it cleaner as it eliminates the tmp file.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However, the original problem remains.&amp;nbsp; If I plug in the find command to do a rm -r, and the DIR directory is older than the -mtime, it will delete the DIR directory as well.&amp;nbsp; I just tried this out and it did exactly that.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;find / -type d -name DIR |\&lt;/P&gt;&lt;P&gt;(&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; while read TMP; do&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; find $TMP -depth -mtime +95 -print -exec rm -r +&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;done&lt;/P&gt;&lt;P&gt;)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This will find the DIR directories and delete everything older than 95 days.&amp;nbsp; However, if the DIR directory ITSELF is older than 95 days, it gets deleted as well.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there a way to prevent this from happening?&amp;nbsp; Thank you again!!!&lt;/P&gt;</description>
      <pubDate>Wed, 14 Oct 2015 18:31:26 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/finding-and-deleting-sub-directories-by-date/m-p/6802345#M494742</guid>
      <dc:creator>TheJuiceman</dc:creator>
      <dc:date>2015-10-14T18:31:26Z</dc:date>
    </item>
    <item>
      <title>Re: Finding and deleting sub-directories by date</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/finding-and-deleting-sub-directories-by-date/m-p/6802350#M494743</link>
      <description>&lt;P&gt;&amp;gt; Is there a way to prevent this from happening?&amp;nbsp; Thank you again!!!&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; I'll try again.&lt;BR /&gt;&lt;BR /&gt;&amp;gt; [...] "find . -mtime +95 -print -exec rm -r + "&lt;BR /&gt;&lt;BR /&gt;&amp;gt; If I cd into the DIR directory prior to the rm statement, it will not&lt;BR /&gt;&amp;gt; delete the DIR directory (since it is in it), but I will get a rm&lt;BR /&gt;&amp;gt; error saying it could not delete it&amp;nbsp; (rm:&amp;nbsp; cannot remove .. or . )&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; If "." is the biggest problem, then consider:&lt;BR /&gt;&lt;BR /&gt;mba$&amp;nbsp; find . -exec echo {} \;&lt;BR /&gt;.&lt;BR /&gt;./test2&lt;BR /&gt;./test2/fred&lt;BR /&gt;&lt;BR /&gt;mba$&amp;nbsp; find . '!' -name . -exec echo {} \;&lt;BR /&gt;./test2&lt;BR /&gt;./test2/fred&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; Does adding "'!' -name ." not work?&lt;/P&gt;</description>
      <pubDate>Wed, 14 Oct 2015 18:52:19 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/finding-and-deleting-sub-directories-by-date/m-p/6802350#M494743</guid>
      <dc:creator>Steven Schweda</dc:creator>
      <dc:date>2015-10-14T18:52:19Z</dc:date>
    </item>
    <item>
      <title>Re: Finding and deleting sub-directories by date</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/finding-and-deleting-sub-directories-by-date/m-p/6802355#M494744</link>
      <description>&lt;P&gt;By cd into the directory and excluding ".", that does in fact stop the problem.&amp;nbsp; I would have thought there would be a "cleaner" way to do this.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;find / -type d -name DIR |\&lt;/P&gt;&lt;P&gt;(&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; while read TMP; do&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; cd $TMP&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;find . ! -name . -depth -mtime +95 -print -exec rm -r +&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; done&lt;/P&gt;&lt;P&gt;)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks again.&lt;/P&gt;</description>
      <pubDate>Wed, 14 Oct 2015 18:59:34 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/finding-and-deleting-sub-directories-by-date/m-p/6802355#M494744</guid>
      <dc:creator>TheJuiceman</dc:creator>
      <dc:date>2015-10-14T18:59:34Z</dc:date>
    </item>
  </channel>
</rss>

