<?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: shell script in Operating System - Linux</title>
    <link>https://community.hpe.com/t5/operating-system-linux/shell-script/m-p/3820232#M100265</link>
    <description>The key is to use touch to create two reference files and then use the -newer option of find.&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;TDIR=${TMPDIR:-/var/tmp}&lt;BR /&gt;typeset T1=${TDIR}/Ref_1.${$}&lt;BR /&gt;typeset T2=${TDIR}/Ref_2.${$}&lt;BR /&gt;typeset BKDIR=/xxx/Backup&lt;BR /&gt;typeset SRCDIR=/xxx/yyy&lt;BR /&gt;typeset -i STAT=0&lt;BR /&gt;typeset FNAME=""&lt;BR /&gt;typeset DESTNAME=""&lt;BR /&gt;cd ${SRCDIR}&lt;BR /&gt;STAT=${?}&lt;BR /&gt;if [[ ${STAT} -ne 0 ]]&lt;BR /&gt;  then&lt;BR /&gt;    echo "Can't cd to ${SRCDIR}" &amp;gt;&amp;amp;2&lt;BR /&gt;    exit ${STAT}&lt;BR /&gt;  fi&lt;BR /&gt;touch -t 200607090659.59 ${T1}&lt;BR /&gt;touch -t 200607092100.01 ${T2}&lt;BR /&gt;find . -type f \( -newer ${T1} -a ! -newer ${T2} \) -print | while read FNAME&lt;BR /&gt;  do&lt;BR /&gt;     DESTNAME="${DESTDIR}/${FNAME}"&lt;BR /&gt;     if [[ -f "{DESTNAME}" ]]&lt;BR /&gt;       then&lt;BR /&gt;         echo "${DESTNAME} exists; not copied" &amp;gt;72&lt;BR /&gt;       else&lt;BR /&gt;         cp -p "{FNAME}" "${DESTNAME}"&lt;BR /&gt;         STAT=${?}&lt;BR /&gt;         if [[ ${STAT} -eq 0 ]]&lt;BR /&gt;           then&lt;BR /&gt;             rm -f "${FNAME}"&lt;BR /&gt;           else&lt;BR /&gt;             echo "Cp of ${FNAME} failed; status ${STAT}" &amp;gt;&amp;amp;2&lt;BR /&gt;           fi&lt;BR /&gt;       fi&lt;BR /&gt;  done&lt;BR /&gt;rm -f ${T1} ${T2}&lt;BR /&gt;exit ${STAT}&lt;BR /&gt;     &lt;BR /&gt;&lt;BR /&gt;man find, touch for details.</description>
    <pubDate>Sun, 09 Jul 2006 23:29:40 GMT</pubDate>
    <dc:creator>A. Clay Stephenson</dc:creator>
    <dc:date>2006-07-09T23:29:40Z</dc:date>
    <item>
      <title>shell script</title>
      <link>https://community.hpe.com/t5/operating-system-linux/shell-script/m-p/3820231#M100264</link>
      <description>Hi,&lt;BR /&gt;My system create files everyday in specific file system.&lt;BR /&gt; &lt;BR /&gt;so I want to make a script which find out specific files created in specific time &lt;BR /&gt;and delete it after backup to other directory.&lt;BR /&gt; &lt;BR /&gt;For example, The script find out file which created from 07:00 from 21:00, &lt;BR /&gt;and copy that file to backup directory and delete the original.&lt;BR /&gt;&lt;BR /&gt;#ls -al  A&lt;BR /&gt;-rw-rw---- 1 ftp  sys 20971520 Jul 13 09:41 a&lt;BR /&gt;-rw-rw---- 1 ftp  sys 20971520 Jul 12 06:40 b&lt;BR /&gt;-rw-rw---- 1 ftp  sys 20972544 Jul 11 06:20 c&lt;BR /&gt;-rw-rw---- 1 ftp  sys 20971520 Jul 10 22:01 d&lt;BR /&gt;-rw-rw---- 1 ftp  sys 20972544 Jul 10 21:44 e&lt;BR /&gt;-rw-rw---- 1 ftp  sys 20972544 Jul 10 20:30 f&lt;BR /&gt;-rw-rw---- 1 ftp  sys 20971520 Jul 10 19:20 g&lt;BR /&gt;-rw-rw---- 1 ftp  sys 20972544 Jul 10 08:10 h&lt;BR /&gt;-rw-rw---- 1 ftp  sys 20972544 Jul  8 21:05 i&lt;BR /&gt;-rw-rw---- 1 ftp  sys 20971520 Jul  8 20:30 j&lt;BR /&gt;&lt;BR /&gt;Can anyone help? &lt;BR /&gt;Thanks,&lt;BR /&gt;zungwon</description>
      <pubDate>Sun, 09 Jul 2006 22:47:14 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/shell-script/m-p/3820231#M100264</guid>
      <dc:creator>???_185</dc:creator>
      <dc:date>2006-07-09T22:47:14Z</dc:date>
    </item>
    <item>
      <title>Re: shell script</title>
      <link>https://community.hpe.com/t5/operating-system-linux/shell-script/m-p/3820232#M100265</link>
      <description>The key is to use touch to create two reference files and then use the -newer option of find.&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;TDIR=${TMPDIR:-/var/tmp}&lt;BR /&gt;typeset T1=${TDIR}/Ref_1.${$}&lt;BR /&gt;typeset T2=${TDIR}/Ref_2.${$}&lt;BR /&gt;typeset BKDIR=/xxx/Backup&lt;BR /&gt;typeset SRCDIR=/xxx/yyy&lt;BR /&gt;typeset -i STAT=0&lt;BR /&gt;typeset FNAME=""&lt;BR /&gt;typeset DESTNAME=""&lt;BR /&gt;cd ${SRCDIR}&lt;BR /&gt;STAT=${?}&lt;BR /&gt;if [[ ${STAT} -ne 0 ]]&lt;BR /&gt;  then&lt;BR /&gt;    echo "Can't cd to ${SRCDIR}" &amp;gt;&amp;amp;2&lt;BR /&gt;    exit ${STAT}&lt;BR /&gt;  fi&lt;BR /&gt;touch -t 200607090659.59 ${T1}&lt;BR /&gt;touch -t 200607092100.01 ${T2}&lt;BR /&gt;find . -type f \( -newer ${T1} -a ! -newer ${T2} \) -print | while read FNAME&lt;BR /&gt;  do&lt;BR /&gt;     DESTNAME="${DESTDIR}/${FNAME}"&lt;BR /&gt;     if [[ -f "{DESTNAME}" ]]&lt;BR /&gt;       then&lt;BR /&gt;         echo "${DESTNAME} exists; not copied" &amp;gt;72&lt;BR /&gt;       else&lt;BR /&gt;         cp -p "{FNAME}" "${DESTNAME}"&lt;BR /&gt;         STAT=${?}&lt;BR /&gt;         if [[ ${STAT} -eq 0 ]]&lt;BR /&gt;           then&lt;BR /&gt;             rm -f "${FNAME}"&lt;BR /&gt;           else&lt;BR /&gt;             echo "Cp of ${FNAME} failed; status ${STAT}" &amp;gt;&amp;amp;2&lt;BR /&gt;           fi&lt;BR /&gt;       fi&lt;BR /&gt;  done&lt;BR /&gt;rm -f ${T1} ${T2}&lt;BR /&gt;exit ${STAT}&lt;BR /&gt;     &lt;BR /&gt;&lt;BR /&gt;man find, touch for details.</description>
      <pubDate>Sun, 09 Jul 2006 23:29:40 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/shell-script/m-p/3820232#M100265</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2006-07-09T23:29:40Z</dc:date>
    </item>
  </channel>
</rss>

