<?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 question in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/script-question/m-p/2652938#M46476</link>
    <description>Hi Anthony,&lt;BR /&gt;&lt;BR /&gt;Something along these lines:&lt;BR /&gt;&lt;BR /&gt;======================================&lt;BR /&gt;month=`date "+%b" | tr [a-z] [A-Z]`&lt;BR /&gt;test -d /archive/moe/log/${month} || mkdir -p /archive/moe/log/${month}&lt;BR /&gt;filename=" "&lt;BR /&gt;cd /log/moe&lt;BR /&gt;for filename in `find . \( -name 'MoeL*' -o -name 'MoeP*.log' -o -name 'moe_s*' -o&lt;BR /&gt;-name 'moe.log*' \) -mtime +3 -print`&lt;BR /&gt;do&lt;BR /&gt;mv $filename /archive/logbackup/$filename&lt;BR /&gt;done&lt;BR /&gt;cd /archive&lt;BR /&gt;file=`find /archive/logbackup -type f -print|wc -l`&lt;BR /&gt;if [ $file -eq 0 ]&lt;BR /&gt;then&lt;BR /&gt;exit&lt;BR /&gt;else&lt;BR /&gt;compress *&lt;BR /&gt;mv *.Z /archive/moe/log/${month}/&lt;BR /&gt;cd /archive/logbackup&lt;BR /&gt;rm *&lt;BR /&gt;fi&lt;BR /&gt;========================================&lt;BR /&gt;&lt;BR /&gt;I'm assuming on Feb 1st, you don't mind those files from Jan 31st, say, ending up in the FEB directory.&lt;BR /&gt;&lt;BR /&gt;Rgds, Robin.</description>
    <pubDate>Fri, 25 Jan 2002 14:12:59 GMT</pubDate>
    <dc:creator>Robin Wakefield</dc:creator>
    <dc:date>2002-01-25T14:12:59Z</dc:date>
    <item>
      <title>script question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-question/m-p/2652937#M46475</link>
      <description>Hi All,&lt;BR /&gt;&lt;BR /&gt;I am running a following script to look for 3 days old file (file has a time stamp with  it) and mv it to JAN directory, now what I want is that  when the Feb starts, script will create dir by the name FEB and start mv the feb files to FEB dir and so on, any suggestion, Thanks in advance.&lt;BR /&gt;&lt;BR /&gt;filename=" "&lt;BR /&gt;cd /log/moe&lt;BR /&gt;for filename in `find . \( -name 'MoeL*' -o -name 'MoeP*.log' -o -name 'moe_s*' -o&lt;BR /&gt; -name 'moe.log*' \) -mtime +3 -print`&lt;BR /&gt;do&lt;BR /&gt;mv $filename /archive/logbackup/$filename &lt;BR /&gt;done&lt;BR /&gt;cd /archive&lt;BR /&gt;file=`find /archive/logbackup -type f -print|wc -l`&lt;BR /&gt;if [ $file -eq 0 ]&lt;BR /&gt;then&lt;BR /&gt;exit&lt;BR /&gt;else&lt;BR /&gt;compress *&lt;BR /&gt;mv *.Z /archive/moe/log/JAN/&lt;BR /&gt;cd /archive/logbackup&lt;BR /&gt;rm *&lt;BR /&gt;fi&lt;BR /&gt;</description>
      <pubDate>Fri, 25 Jan 2002 14:05:00 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-question/m-p/2652937#M46475</guid>
      <dc:creator>Anthony khan</dc:creator>
      <dc:date>2002-01-25T14:05:00Z</dc:date>
    </item>
    <item>
      <title>Re: script question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-question/m-p/2652938#M46476</link>
      <description>Hi Anthony,&lt;BR /&gt;&lt;BR /&gt;Something along these lines:&lt;BR /&gt;&lt;BR /&gt;======================================&lt;BR /&gt;month=`date "+%b" | tr [a-z] [A-Z]`&lt;BR /&gt;test -d /archive/moe/log/${month} || mkdir -p /archive/moe/log/${month}&lt;BR /&gt;filename=" "&lt;BR /&gt;cd /log/moe&lt;BR /&gt;for filename in `find . \( -name 'MoeL*' -o -name 'MoeP*.log' -o -name 'moe_s*' -o&lt;BR /&gt;-name 'moe.log*' \) -mtime +3 -print`&lt;BR /&gt;do&lt;BR /&gt;mv $filename /archive/logbackup/$filename&lt;BR /&gt;done&lt;BR /&gt;cd /archive&lt;BR /&gt;file=`find /archive/logbackup -type f -print|wc -l`&lt;BR /&gt;if [ $file -eq 0 ]&lt;BR /&gt;then&lt;BR /&gt;exit&lt;BR /&gt;else&lt;BR /&gt;compress *&lt;BR /&gt;mv *.Z /archive/moe/log/${month}/&lt;BR /&gt;cd /archive/logbackup&lt;BR /&gt;rm *&lt;BR /&gt;fi&lt;BR /&gt;========================================&lt;BR /&gt;&lt;BR /&gt;I'm assuming on Feb 1st, you don't mind those files from Jan 31st, say, ending up in the FEB directory.&lt;BR /&gt;&lt;BR /&gt;Rgds, Robin.</description>
      <pubDate>Fri, 25 Jan 2002 14:12:59 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-question/m-p/2652938#M46476</guid>
      <dc:creator>Robin Wakefield</dc:creator>
      <dc:date>2002-01-25T14:12:59Z</dc:date>
    </item>
    <item>
      <title>Re: script question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-question/m-p/2652939#M46477</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;If you want to use the month as of the time the script runs then do something like this:&lt;BR /&gt;&lt;BR /&gt;.&lt;BR /&gt;.&lt;BR /&gt;.&lt;BR /&gt;compress *&lt;BR /&gt;MONTH=`date +%b | tr "[:lower:]" "[:upper:]"`&lt;BR /&gt;if [ ! -d /archive/moe/log/${MONTH} ]&lt;BR /&gt;then&lt;BR /&gt;mkdir /archive/moe/log/${MONTH}&lt;BR /&gt;fi&lt;BR /&gt;mv *.Z /archive/moe/log/${MONTH}&lt;BR /&gt;&lt;BR /&gt;Darrell</description>
      <pubDate>Fri, 25 Jan 2002 14:18:49 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-question/m-p/2652939#M46477</guid>
      <dc:creator>Darrell Allen</dc:creator>
      <dc:date>2002-01-25T14:18:49Z</dc:date>
    </item>
    <item>
      <title>Re: script question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-question/m-p/2652940#M46478</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;what about this:&lt;BR /&gt;&lt;BR /&gt;month=`date +%b|awk '{sub("\.","",$1);print toupper($1)}'`&lt;BR /&gt;[ ! -d /archive/moe/log/$month ] &amp;amp;&amp;amp; mkdir /archive/moe/log/$month&lt;BR /&gt;cd /log/moe&lt;BR /&gt;find . \( -name 'MoeL*' -o -name 'MoeP*.log' -o -name 'moe_s*' -o -name 'moe.log*' \) -mtime +3 -print |&lt;BR /&gt;while read filename&lt;BR /&gt;do &lt;BR /&gt;  mv $filename /archive/moe/log/$month&lt;BR /&gt;  compress /archive/moe/log/$month&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;Regards</description>
      <pubDate>Fri, 25 Jan 2002 14:36:48 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-question/m-p/2652940#M46478</guid>
      <dc:creator>Andreas Voss</dc:creator>
      <dc:date>2002-01-25T14:36:48Z</dc:date>
    </item>
    <item>
      <title>Re: script question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-question/m-p/2652941#M46479</link>
      <description>Sorry,&lt;BR /&gt;&lt;BR /&gt;Line:&lt;BR /&gt;compress /archive/moe/log/$month &lt;BR /&gt;&lt;BR /&gt;should be:&lt;BR /&gt;compress /archive/moe/log/$month/$filename&lt;BR /&gt;&lt;BR /&gt;Regards &lt;BR /&gt;</description>
      <pubDate>Fri, 25 Jan 2002 14:40:01 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-question/m-p/2652941#M46479</guid>
      <dc:creator>Andreas Voss</dc:creator>
      <dc:date>2002-01-25T14:40:01Z</dc:date>
    </item>
    <item>
      <title>Re: script question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-question/m-p/2652942#M46480</link>
      <description>Is there any way to avoid sending moe.log.02-01-31 files to FEB directory, I want these files in JAN dir.</description>
      <pubDate>Fri, 25 Jan 2002 16:02:39 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-question/m-p/2652942#M46480</guid>
      <dc:creator>Anthony khan</dc:creator>
      <dc:date>2002-01-25T16:02:39Z</dc:date>
    </item>
    <item>
      <title>Re: script question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-question/m-p/2652943#M46481</link>
      <description>Right before the move you can check for month and day.&lt;BR /&gt;&lt;BR /&gt;If it is Feb day 01 mv to Jan&lt;BR /&gt;else&lt;BR /&gt;mv to Feb.&lt;BR /&gt;&lt;BR /&gt;This is not the exact syntax of course but with all the excellecent examples for using the date command in the other posts. I am sure you get they syntax from those examples.</description>
      <pubDate>Fri, 25 Jan 2002 16:37:58 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-question/m-p/2652943#M46481</guid>
      <dc:creator>Krishna Prasad</dc:creator>
      <dc:date>2002-01-25T16:37:58Z</dc:date>
    </item>
    <item>
      <title>Re: script question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-question/m-p/2652944#M46482</link>
      <description>Hi again,&lt;BR /&gt;&lt;BR /&gt;You can change your criteria for setting the target directory.  Instead of baseing it on the current date you can use the name of the file itself.&lt;BR /&gt;&lt;BR /&gt;Here's a snippet of code to get you going.  This assumes the files are named *log.yy-mm-dd and you want to use mm to determine which directory to place the file in.&lt;BR /&gt;&lt;BR /&gt;for i in `ls *log*`&lt;BR /&gt;do&lt;BR /&gt;month=`echo $i | awk -F. '{print $NF}' | cut -c4-5`&lt;BR /&gt;case $month&lt;BR /&gt;in&lt;BR /&gt;01) MONTH=JAN;;&lt;BR /&gt;02) MONTH=FEB;;&lt;BR /&gt;.&lt;BR /&gt;.&lt;BR /&gt;.&lt;BR /&gt;12) MONTH=DEC;;&lt;BR /&gt;esac&lt;BR /&gt;compress $i &lt;BR /&gt;if [ ! -d ${MONTH} ] &lt;BR /&gt;then &lt;BR /&gt;mkdir ${MONTH} &lt;BR /&gt;fi &lt;BR /&gt;mv $i.Z ${MONTH} &lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;Darrell</description>
      <pubDate>Fri, 25 Jan 2002 20:53:24 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-question/m-p/2652944#M46482</guid>
      <dc:creator>Darrell Allen</dc:creator>
      <dc:date>2002-01-25T20:53:24Z</dc:date>
    </item>
  </channel>
</rss>

