<?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: Unix Shell Script in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/unix-shell-script/m-p/2727315#M721763</link>
    <description>Hello,&lt;BR /&gt;Carlos is right.&lt;BR /&gt;It will remove all files recursively under the directory.&lt;BR /&gt;&lt;BR /&gt;do a list of files&lt;BR /&gt;find $dir -type f -mtime +20 -exec ll {} \;&lt;BR /&gt;then&lt;BR /&gt;remove them&lt;BR /&gt;find $dir -type f -mtime +20 -exec rm {} \;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Thanks&lt;BR /&gt;&lt;BR /&gt;</description>
    <pubDate>Mon, 20 May 2002 08:07:48 GMT</pubDate>
    <dc:creator>T G Manikandan</dc:creator>
    <dc:date>2002-05-20T08:07:48Z</dc:date>
    <item>
      <title>Unix Shell Script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/unix-shell-script/m-p/2727312#M721760</link>
      <description>find / -mtime +30 -print &lt;BR /&gt;&lt;BR /&gt;i need to write a script(UNIX) to delete files created older than 30 days &lt;BR /&gt;i'm only a beginner and i only found the above function -mtime &lt;BR /&gt;&lt;BR /&gt;i tried this : &lt;BR /&gt;for fn in `ls *.*` &lt;BR /&gt;do &lt;BR /&gt;&lt;BR /&gt;if [find ${WKDIR}/${fn} -mtime +30]; then &lt;BR /&gt;rm ${fn} &lt;BR /&gt;&lt;BR /&gt;fi &lt;BR /&gt;&lt;BR /&gt;done &lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;*but this doesnt work &lt;BR /&gt;can someone help? &lt;BR /&gt;&lt;BR /&gt;thanks a lot..reply soon..urgent&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Mon, 20 May 2002 07:51:52 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/unix-shell-script/m-p/2727312#M721760</guid>
      <dc:creator>pauline_1</dc:creator>
      <dc:date>2002-05-20T07:51:52Z</dc:date>
    </item>
    <item>
      <title>Re: Unix Shell Script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/unix-shell-script/m-p/2727313#M721761</link>
      <description>&lt;BR /&gt;Hello,&lt;BR /&gt;&lt;BR /&gt;find $dir -type f -mtime +20 -exec rm {} \;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Thanks&lt;BR /&gt;</description>
      <pubDate>Mon, 20 May 2002 07:59:30 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/unix-shell-script/m-p/2727313#M721761</guid>
      <dc:creator>T G Manikandan</dc:creator>
      <dc:date>2002-05-20T07:59:30Z</dc:date>
    </item>
    <item>
      <title>Re: Unix Shell Script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/unix-shell-script/m-p/2727314#M721762</link>
      <description>&lt;BR /&gt;cd $DIR&lt;BR /&gt;&lt;BR /&gt;find . -mtime +30 -type f | xargs rm &lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Be aware that this command will do a recursive list of all dirs bellow $DIR, and delte all files older that 30 days.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Check what this will do first:&lt;BR /&gt;&lt;BR /&gt;ll $( find . -mtime +30 -type f ) | more&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Mon, 20 May 2002 08:01:01 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/unix-shell-script/m-p/2727314#M721762</guid>
      <dc:creator>Carlos Fernandez Riera</dc:creator>
      <dc:date>2002-05-20T08:01:01Z</dc:date>
    </item>
    <item>
      <title>Re: Unix Shell Script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/unix-shell-script/m-p/2727315#M721763</link>
      <description>Hello,&lt;BR /&gt;Carlos is right.&lt;BR /&gt;It will remove all files recursively under the directory.&lt;BR /&gt;&lt;BR /&gt;do a list of files&lt;BR /&gt;find $dir -type f -mtime +20 -exec ll {} \;&lt;BR /&gt;then&lt;BR /&gt;remove them&lt;BR /&gt;find $dir -type f -mtime +20 -exec rm {} \;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Thanks&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Mon, 20 May 2002 08:07:48 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/unix-shell-script/m-p/2727315#M721763</guid>
      <dc:creator>T G Manikandan</dc:creator>
      <dc:date>2002-05-20T08:07:48Z</dc:date>
    </item>
    <item>
      <title>Re: Unix Shell Script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/unix-shell-script/m-p/2727316#M721764</link>
      <description>Hi all,&lt;BR /&gt;&lt;BR /&gt;for a specified directory in Unix, i need to do these three things.&lt;BR /&gt;&lt;BR /&gt;1. for files within a month, the files will remain&lt;BR /&gt;2. for files that are more than 4 mths old, these files are to be removed&lt;BR /&gt;3. for files that are between 2nd mth and 4th mth ,these files are to be gzip and tar.&lt;BR /&gt;&lt;BR /&gt;may i know how can u do that in one simgle script?&lt;BR /&gt;&lt;BR /&gt;i dun hav any idea at all..&lt;BR /&gt;is ther any other function i can use?&lt;BR /&gt;pls help..thanks to all~</description>
      <pubDate>Mon, 20 May 2002 08:18:41 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/unix-shell-script/m-p/2727316#M721764</guid>
      <dc:creator>pauline_1</dc:creator>
      <dc:date>2002-05-20T08:18:41Z</dc:date>
    </item>
    <item>
      <title>Re: Unix Shell Script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/unix-shell-script/m-p/2727317#M721765</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;Assuming &lt;BR /&gt;- 4 months = approx 120 days&lt;BR /&gt;- 1 months = approx 30 days&lt;BR /&gt;&lt;BR /&gt;1. for files within a month, the files will remain &lt;BR /&gt;&lt;BR /&gt;# Do nothing&lt;BR /&gt;&lt;BR /&gt;2. for files that are more than 4 mths old, these files are to be removed &lt;BR /&gt;&lt;BR /&gt;# find $dir -mtime +120 -exec rm -f {} \;&lt;BR /&gt;&lt;BR /&gt;3. for files that are between 2nd mth and 4th mth ,these files are to be gzip and tar. &lt;BR /&gt;&lt;BR /&gt;# tar cvf oldfiles.tar `find $dir -mtime +30 -print`&lt;BR /&gt;&lt;BR /&gt;Your script simply executes each in sequence:&lt;BR /&gt;&lt;BR /&gt;archive.sh&lt;BR /&gt;====================================&lt;BR /&gt;#!/sbin/sh&lt;BR /&gt;&lt;BR /&gt;dir=$1&lt;BR /&gt;find $dir -mtime +120 -exec rm -f {} \;&lt;BR /&gt;tar cvf oldfiles.tar `find $dir -mtime +30 -print`&lt;BR /&gt;====================================&lt;BR /&gt;&lt;BR /&gt;To execute, e.g.&lt;BR /&gt;&lt;BR /&gt;# archive.sh /tmp/testdir&lt;BR /&gt;&lt;BR /&gt;WARNING: Always test your script first on a test directory before actually running it on a production basis.&lt;BR /&gt;&lt;BR /&gt;Hope this helps. Regards.&lt;BR /&gt;&lt;BR /&gt;Steven Sim Kok Leong</description>
      <pubDate>Mon, 20 May 2002 08:36:30 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/unix-shell-script/m-p/2727317#M721765</guid>
      <dc:creator>Steven Sim Kok Leong</dc:creator>
      <dc:date>2002-05-20T08:36:30Z</dc:date>
    </item>
    <item>
      <title>Re: Unix Shell Script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/unix-shell-script/m-p/2727318#M721766</link>
      <description>Two ideas...&lt;BR /&gt;&lt;BR /&gt;If you move older files to another(s) directories you will never find any file older that x months.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;See man sh-posix.... search test&lt;BR /&gt;&lt;BR /&gt;See man touch&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;touch MMDDhhmm date1&lt;BR /&gt;touch MMDDhhmm date2 # older date&lt;BR /&gt;&lt;BR /&gt;for file in *&lt;BR /&gt;do&lt;BR /&gt;&lt;BR /&gt;if  ( $file -nt $date1 ) ; then&lt;BR /&gt;&lt;BR /&gt;echo $file &amp;gt;&amp;gt; files_to_remove&lt;BR /&gt;&lt;BR /&gt;else if ( $file -nt $date2 ); then&lt;BR /&gt;&lt;BR /&gt;echo $file &amp;gt;&amp;gt; files_to_tar&lt;BR /&gt;fi&lt;BR /&gt;fi&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt; It is not checked, only the basis of a script... &lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Good Luck.&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Mon, 20 May 2002 08:49:00 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/unix-shell-script/m-p/2727318#M721766</guid>
      <dc:creator>Carlos Fernandez Riera</dc:creator>
      <dc:date>2002-05-20T08:49:00Z</dc:date>
    </item>
    <item>
      <title>Re: Unix Shell Script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/unix-shell-script/m-p/2727319#M721767</link>
      <description>if under that directory there are sub-directories... will they be affected?</description>
      <pubDate>Tue, 21 May 2002 02:45:27 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/unix-shell-script/m-p/2727319#M721767</guid>
      <dc:creator>pauline_1</dc:creator>
      <dc:date>2002-05-21T02:45:27Z</dc:date>
    </item>
    <item>
      <title>Re: Unix Shell Script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/unix-shell-script/m-p/2727320#M721768</link>
      <description>Yes all sub dirs will be processed (as mentioned by Carlos already). If you want to exclude a dir from being traversed you can do this ..&lt;BR /&gt;# cd /dira&lt;BR /&gt;# find . \( -name dirb -prune \) -o -mtime +30 -exec rm -f {} \;&lt;BR /&gt;That will exclude "dirb" from being "processed". Another option you can use is the "-newer" option. For example you want to list all files under /dira which has a timestamp later than say May08 02:05am you can do this ..&lt;BR /&gt;# touch 05080205 ref&lt;BR /&gt;===&amp;gt; create an "empty file" dated May08 02:05&lt;BR /&gt;# cd /dira&lt;BR /&gt;# find . -newer /tmp/ref -exec ll {} \;&lt;BR /&gt;===&amp;gt; list all files newer than /tmp/ref&lt;BR /&gt;</description>
      <pubDate>Tue, 21 May 2002 03:08:30 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/unix-shell-script/m-p/2727320#M721768</guid>
      <dc:creator>S.K. Chan</dc:creator>
      <dc:date>2002-05-21T03:08:30Z</dc:date>
    </item>
    <item>
      <title>Re: Unix Shell Script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/unix-shell-script/m-p/2727321#M721769</link>
      <description>thanks to all~ :)&lt;BR /&gt;appreciated..script completed.</description>
      <pubDate>Tue, 21 May 2002 05:42:43 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/unix-shell-script/m-p/2727321#M721769</guid>
      <dc:creator>pauline_1</dc:creator>
      <dc:date>2002-05-21T05:42:43Z</dc:date>
    </item>
  </channel>
</rss>

