<?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: Help with scripting in Operating System - Linux</title>
    <link>https://community.hpe.com/t5/operating-system-linux/help-with-scripting/m-p/3680245#M102879</link>
    <description>First part like this:&lt;BR /&gt;&lt;BR /&gt;MONTH=`date +%B`&lt;BR /&gt;mkdir /someotherdir/$MONTH&lt;BR /&gt;&lt;BR /&gt;TODAY=`date +%b" "%d`&lt;BR /&gt;&lt;BR /&gt;for FILE in `ll /somedir | grep -v "$TODAY" |awk '{print $9}`&lt;BR /&gt;do&lt;BR /&gt;mv $FILE /someotherdir/$MONTH&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;Rgds...Geoff</description>
    <pubDate>Mon, 28 Nov 2005 15:03:07 GMT</pubDate>
    <dc:creator>Geoff Wild</dc:creator>
    <dc:date>2005-11-28T15:03:07Z</dc:date>
    <item>
      <title>Help with scripting</title>
      <link>https://community.hpe.com/t5/operating-system-linux/help-with-scripting/m-p/3680244#M102878</link>
      <description>Hey scripting gurus.&lt;BR /&gt;&lt;BR /&gt;I'd like some help in scripting the following.&lt;BR /&gt;&lt;BR /&gt;A daily job that will analyze the files in a file system and then move off the files created the previous day to a heirarchical directory structure.  &lt;BR /&gt;&lt;BR /&gt;Where it gets a bit difficult is that they want to move it to a directory structure such as:&lt;BR /&gt;&lt;BR /&gt;/Year/Month&lt;BR /&gt;/Year/Month/End Of Month&lt;BR /&gt;&lt;BR /&gt;ex:&lt;BR /&gt;&lt;BR /&gt;/Year/January&lt;BR /&gt;/Year/Januar/End Of Month&lt;BR /&gt;/Year/February&lt;BR /&gt;/Year/February/End of Month&lt;BR /&gt;&lt;BR /&gt;So all files for the month, except the last day of the month get moved into the month directory. The files for the last day of the month get moved into the month/end of month directory.&lt;BR /&gt;&lt;BR /&gt;The script will have to create the directories if they don't exist at the time the script is run.  (first day of new month).&lt;BR /&gt;&lt;BR /&gt;TIA and points for all responses.&lt;BR /&gt;&lt;BR /&gt;Sean&lt;BR /&gt;</description>
      <pubDate>Mon, 28 Nov 2005 14:46:22 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/help-with-scripting/m-p/3680244#M102878</guid>
      <dc:creator>Sean OB_1</dc:creator>
      <dc:date>2005-11-28T14:46:22Z</dc:date>
    </item>
    <item>
      <title>Re: Help with scripting</title>
      <link>https://community.hpe.com/t5/operating-system-linux/help-with-scripting/m-p/3680245#M102879</link>
      <description>First part like this:&lt;BR /&gt;&lt;BR /&gt;MONTH=`date +%B`&lt;BR /&gt;mkdir /someotherdir/$MONTH&lt;BR /&gt;&lt;BR /&gt;TODAY=`date +%b" "%d`&lt;BR /&gt;&lt;BR /&gt;for FILE in `ll /somedir | grep -v "$TODAY" |awk '{print $9}`&lt;BR /&gt;do&lt;BR /&gt;mv $FILE /someotherdir/$MONTH&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;Rgds...Geoff</description>
      <pubDate>Mon, 28 Nov 2005 15:03:07 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/help-with-scripting/m-p/3680245#M102879</guid>
      <dc:creator>Geoff Wild</dc:creator>
      <dc:date>2005-11-28T15:03:07Z</dc:date>
    </item>
    <item>
      <title>Re: Help with scripting</title>
      <link>https://community.hpe.com/t5/operating-system-linux/help-with-scripting/m-p/3680246#M102880</link>
      <description>No matter what you are told the problem as stated cannot be done for the simple reason that time of creation is not known. If you do know it, you only know it by accident if the modification or change time (these are not the same) happen to also be the time of creation. Creation time metadata simply don't exist in UNIX.</description>
      <pubDate>Mon, 28 Nov 2005 15:13:29 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/help-with-scripting/m-p/3680246#M102880</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2005-11-28T15:13:29Z</dc:date>
    </item>
    <item>
      <title>Re: Help with scripting</title>
      <link>https://community.hpe.com/t5/operating-system-linux/help-with-scripting/m-p/3680247#M102881</link>
      <description>Hi Sean:&lt;BR /&gt;&lt;BR /&gt;It's easy to determine the first and last day of any month (including leap year) by simply comparing the current day to a predefined array of values (and adding one to February if the year is evenly divisible by four).&lt;BR /&gt;&lt;BR /&gt;Given that, you can trigger a 'mkdir' to create any backup directory with the appropriate name.&lt;BR /&gt;&lt;BR /&gt;Then, you might let your script 'touch' a "reference" file for the LAST day of the month thusly:&lt;BR /&gt;&lt;BR /&gt;# touch -amt 11302359 /tmp/myref&lt;BR /&gt;&lt;BR /&gt;Now, use 'find' to move everything but the last day to the month's directory:&lt;BR /&gt;&lt;BR /&gt;# find /sourcedir -type f ! -newer /tmp/myref -exec mv {} /destdir \;&lt;BR /&gt;&lt;BR /&gt;To move the last of the month's files to the end-of-month directory, simply drop the negatation ( the bang synbol, "!" ):&lt;BR /&gt;&lt;BR /&gt;# find /sourcedir -type f -newer /tmp/myref -exec mv {} /destdir \;&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Mon, 28 Nov 2005 15:58:18 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/help-with-scripting/m-p/3680247#M102881</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2005-11-28T15:58:18Z</dc:date>
    </item>
    <item>
      <title>Re: Help with scripting</title>
      <link>https://community.hpe.com/t5/operating-system-linux/help-with-scripting/m-p/3680248#M102882</link>
      <description>Here's how you can get the last day of the current month:&lt;BR /&gt;&lt;BR /&gt;set -- `cal ` ; eval LDAY=\${$#}&lt;BR /&gt;echo $LDAY&lt;BR /&gt;&lt;BR /&gt;CURMONTH=`date +%b`&lt;BR /&gt;Then, grep for "$CURMONTH $LDAY"&lt;BR /&gt;&lt;BR /&gt;Rgds...Geoff&lt;BR /&gt;</description>
      <pubDate>Mon, 28 Nov 2005 15:58:56 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/help-with-scripting/m-p/3680248#M102882</guid>
      <dc:creator>Geoff Wild</dc:creator>
      <dc:date>2005-11-28T15:58:56Z</dc:date>
    </item>
    <item>
      <title>Re: Help with scripting</title>
      <link>https://community.hpe.com/t5/operating-system-linux/help-with-scripting/m-p/3680249#M102883</link>
      <description>The way you have phrased this question I am assuming that some process or processes are creating these files and not people and you are just archiving them.&lt;BR /&gt;&lt;BR /&gt;No problem, couldn't be simpler.&lt;BR /&gt;&lt;BR /&gt;Set up a cron job to run every day a few minuets after midnight.&lt;BR /&gt;&lt;BR /&gt;Then based on the current date decide what your subdirectory is going to be and move the files with a modification data of greater than today&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/ksh&lt;BR /&gt;&lt;BR /&gt;date -u +%E" "%B" "%d | read YEAR MONTH DAY&lt;BR /&gt;&lt;BR /&gt;LASTMONTH="you figure it out hint, case statment"&lt;BR /&gt;&lt;BR /&gt;SUBDIR=${YEAR}/${MONTH}&lt;BR /&gt;&lt;BR /&gt;# these work like if thens but simpler to read&lt;BR /&gt;# if the first test case succeeds the &amp;amp;&amp;amp; makes shell run the next&lt;BR /&gt;# if the first test case fails it doesn't bother running&lt;BR /&gt;# the next test case sense the entire line has already failed&lt;BR /&gt;[ $MONTH = "Janruary" ] &amp;amp;&amp;amp; [ $DAY = 1 ] &amp;amp;&amp;amp; YEAR=$(expr ${YEAR} - 1)&lt;BR /&gt;[ $DAY = 1 ] &amp;amp;&amp;amp; SUBDIR=${YEAR}/${LASTMONTH}/eom&lt;BR /&gt;[ ! -d $SUBDIR ] &amp;amp;&amp;amp; mkdir -p $SUBDIR &lt;BR /&gt;&lt;BR /&gt;find . -mtime +1 -exec mv {}";" $SUBDIR&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;I didn't test that at all so you may have to make a few tweeks here and there, or heck just rewrite it to suit your self.  Thatâ  s just the basic idea though.  Moving the files is the easy part, deciding where to move them is more complicated.&lt;BR /&gt;&lt;BR /&gt;H</description>
      <pubDate>Tue, 29 Nov 2005 16:16:51 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/help-with-scripting/m-p/3680249#M102883</guid>
      <dc:creator>Howard Marshall</dc:creator>
      <dc:date>2005-11-29T16:16:51Z</dc:date>
    </item>
  </channel>
</rss>

