<?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 to run everyday with Exclusion Mechanism in Operating System - Linux</title>
    <link>https://community.hpe.com/t5/operating-system-linux/shell-script-to-run-everyday-with-exclusion-mechanism/m-p/3645520#M102333</link>
    <description>Hi All&lt;BR /&gt;&lt;BR /&gt;Thanks James,Sandman,Rod &amp;amp; Mark&lt;BR /&gt;&lt;BR /&gt;Mark, &lt;BR /&gt;&lt;BR /&gt;I have question for you,&lt;BR /&gt;can you suggest a mechanism or an approach of how to fit in that file that contains the list of directories that HAVE to be included into my above posted script.&lt;BR /&gt;&lt;BR /&gt;Thanks &lt;BR /&gt;Henry</description>
    <pubDate>Tue, 11 Oct 2005 12:28:51 GMT</pubDate>
    <dc:creator>Henry  Richards</dc:creator>
    <dc:date>2005-10-11T12:28:51Z</dc:date>
    <item>
      <title>Shell script to run everyday with Exclusion Mechanism</title>
      <link>https://community.hpe.com/t5/operating-system-linux/shell-script-to-run-everyday-with-exclusion-mechanism/m-p/3645512#M102325</link>
      <description>Hi Guys&lt;BR /&gt;I have this script that runs everyday to Long list (ll in HPUX and ls -la in Solaris)all the files in all the directories.The Script when runs the nextday , captures the difference between previous day's longlist(ll) and currentday longlist (ll) using the  diff command in HPUX  "diff file1 file2 &amp;gt; file12"] and save it to new file titled "result".&lt;BR /&gt;&lt;BR /&gt;Now I want to Add a mechanism for excluding files/directories/file systems from the report if they are known to change as part of regular operation of the system.Rightnow I do not what all the directories and files that are to be excluded so now I am looking to design the script with this capability of excluding some directories/files.&lt;BR /&gt;&lt;BR /&gt;The script is as follows:&lt;BR /&gt;&lt;BR /&gt;#! /usr/bin/sh                                                               &lt;BR /&gt;dt1=`date`                                                                       &lt;BR /&gt;TODAY=`echo $dt1|cut -d" " -f3`        &lt;BR /&gt;set -A DAYS Sat Sun Mon Tue Wed Thu Fri Sat                                  &lt;BR /&gt;set -A MONTHS Dec Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec            &lt;BR /&gt;YESTERDAY=$((`date +%d` -1))           &lt;BR /&gt;MONTH=`date +%m`                       &lt;BR /&gt;YEAR=`date +%Y`                        &lt;BR /&gt;NDAY=`date +%u`                 &lt;BR /&gt;                                                                             &lt;BR /&gt; tfile=$MONTH$TODAY$YEAR.lst                   &lt;BR /&gt;echo $tfile                           &lt;BR /&gt;WEEKDAY=${DAYS[`date +%u`]}                   &lt;BR /&gt;if [ $YESTERDAY -eq "0" ]             &lt;BR /&gt;then                                                                         &lt;BR /&gt;        MONTH=$((MONTH-1))             &lt;BR /&gt;        if [ $MONTH -eq "0" ]           then                            &lt;BR /&gt;                MONTH=12                                                     &lt;BR /&gt;     YEAR=$((YEAR-1))       fi                                                                   &lt;BR /&gt;set `cal $MONTH $YEAR`                  &lt;BR /&gt;shift $(($# - 1))                     &lt;BR /&gt;YESTERDAY=$1                             &lt;BR /&gt;fi                                                                           &lt;BR /&gt;TMONTH=${MONTHS[MONTH]}                       &lt;BR /&gt;yfile=$MONTH$YESTERDAY$YEAR.lst                       &lt;BR /&gt;echo "Y day File Name " $yfile               echo "T Day file Name " $tfile        &lt;BR /&gt;ls -ltR /home/tt/tt2 &amp;gt;$tfile       &lt;BR /&gt;                                          &lt;BR /&gt;diff  $tfile $yfile &amp;gt;result.chg       &lt;BR /&gt;&lt;BR /&gt;I would appreciate if you guys could help me out on this.&lt;BR /&gt;&lt;BR /&gt;Thanks&lt;BR /&gt;Henry</description>
      <pubDate>Mon, 10 Oct 2005 09:16:32 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/shell-script-to-run-everyday-with-exclusion-mechanism/m-p/3645512#M102325</guid>
      <dc:creator>Henry  Richards</dc:creator>
      <dc:date>2005-10-10T09:16:32Z</dc:date>
    </item>
    <item>
      <title>Re: Shell script to run everyday with Exclusion Mechanism</title>
      <link>https://community.hpe.com/t5/operating-system-linux/shell-script-to-run-everyday-with-exclusion-mechanism/m-p/3645513#M102326</link>
      <description>Hi Henry:&lt;BR /&gt;&lt;BR /&gt;I'd consider letting 'find' drive your principal 'ls' so that you can leverage directory selection and perhaps some basic filename selection or exclusion.  For instance:&lt;BR /&gt;&lt;BR /&gt;# find /etc/rc.config.d /sbin -type f ! -name "net*" -a ! -name "vg*" | xargs ls -l &amp;gt; /tmp/results&lt;BR /&gt;&lt;BR /&gt;You could also use simple, stacked 'sed' commands to exclude other candidates before you 'diff' the two days files.  For example:&lt;BR /&gt;&lt;BR /&gt;# sed -e '/clean/d' -e '/set_parms/d' ...&lt;BR /&gt;&lt;BR /&gt;If you like, the later specifications can be self-contained in a script that you pipe the output of the driving 'find' into, thereby creating the "results" to 'diff'.&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Mon, 10 Oct 2005 09:58:59 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/shell-script-to-run-everyday-with-exclusion-mechanism/m-p/3645513#M102326</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2005-10-10T09:58:59Z</dc:date>
    </item>
    <item>
      <title>Re: Shell script to run everyday with Exclusion Mechanism</title>
      <link>https://community.hpe.com/t5/operating-system-linux/shell-script-to-run-everyday-with-exclusion-mechanism/m-p/3645514#M102327</link>
      <description>As mentioned, use the find command and play with its "-prune" option in order to exclude directories that are changed on a consistent basis.&lt;BR /&gt;&lt;BR /&gt;cheers!</description>
      <pubDate>Mon, 10 Oct 2005 11:37:24 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/shell-script-to-run-everyday-with-exclusion-mechanism/m-p/3645514#M102327</guid>
      <dc:creator>Sandman!</dc:creator>
      <dc:date>2005-10-10T11:37:24Z</dc:date>
    </item>
    <item>
      <title>Re: Shell script to run everyday with Exclusion Mechanism</title>
      <link>https://community.hpe.com/t5/operating-system-linux/shell-script-to-run-everyday-with-exclusion-mechanism/m-p/3645515#M102328</link>
      <description>Hi James(JRF) and Sandman&lt;BR /&gt;&lt;BR /&gt;so can I use the&lt;BR /&gt;# find /  -a ! -name "vg*" | xargs ls -l &amp;gt; /tmp/results&lt;BR /&gt;&lt;BR /&gt;instead of ls -ltR&lt;BR /&gt;&lt;BR /&gt;I have a doubt will&lt;BR /&gt;find / -a! name " /dev/ "&lt;BR /&gt;will exclude that whole directory and all its sub-directories &amp;amp; files.&lt;BR /&gt;&lt;BR /&gt;Thanks&lt;BR /&gt;Henry</description>
      <pubDate>Mon, 10 Oct 2005 13:43:36 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/shell-script-to-run-everyday-with-exclusion-mechanism/m-p/3645515#M102328</guid>
      <dc:creator>Henry  Richards</dc:creator>
      <dc:date>2005-10-10T13:43:36Z</dc:date>
    </item>
    <item>
      <title>Re: Shell script to run everyday with Exclusion Mechanism</title>
      <link>https://community.hpe.com/t5/operating-system-linux/shell-script-to-run-everyday-with-exclusion-mechanism/m-p/3645516#M102329</link>
      <description>You can use parenthesis in a find-&lt;BR /&gt; &lt;BR /&gt;Example-&lt;BR /&gt;find / ! \( -name "vg*" -a -path "/dev/*" \) | xargs ls -l &amp;gt; /tmp/results&lt;BR /&gt; &lt;BR /&gt;Note the use of "path" for /dev/*.&lt;BR /&gt; &lt;BR /&gt;HTH&lt;BR /&gt; &lt;BR /&gt;-- Rod Hills</description>
      <pubDate>Mon, 10 Oct 2005 13:53:05 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/shell-script-to-run-everyday-with-exclusion-mechanism/m-p/3645516#M102329</guid>
      <dc:creator>Rodney Hills</dc:creator>
      <dc:date>2005-10-10T13:53:05Z</dc:date>
    </item>
    <item>
      <title>Re: Shell script to run everyday with Exclusion Mechanism</title>
      <link>https://community.hpe.com/t5/operating-system-linux/shell-script-to-run-everyday-with-exclusion-mechanism/m-p/3645517#M102330</link>
      <description>Hi Guys&lt;BR /&gt;&lt;BR /&gt;How do I exclude a particular directory&lt;BR /&gt;or a particular file using the find command&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;I tried  the following command to delete a file ytre.txt located at /dev/first/ytre.txt&lt;BR /&gt;&lt;BR /&gt;find /dev/first  !\(-name "ytre" -a path /dev/first \)|xargs ls -l&lt;BR /&gt;&lt;BR /&gt;But it didn't work&lt;BR /&gt;&lt;BR /&gt;Please let me know the syntax of excluding particular directory/file using the find command&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;your help is appreciated.&lt;BR /&gt;&lt;BR /&gt;Thanks&lt;BR /&gt;Henry&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Mon, 10 Oct 2005 16:32:48 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/shell-script-to-run-everyday-with-exclusion-mechanism/m-p/3645517#M102330</guid>
      <dc:creator>Henry  Richards</dc:creator>
      <dc:date>2005-10-10T16:32:48Z</dc:date>
    </item>
    <item>
      <title>Re: Shell script to run everyday with Exclusion Mechanism</title>
      <link>https://community.hpe.com/t5/operating-system-linux/shell-script-to-run-everyday-with-exclusion-mechanism/m-p/3645518#M102331</link>
      <description>Be sure to use quotes and wildcards-&lt;BR /&gt; &lt;BR /&gt;example-&lt;BR /&gt;&lt;BR /&gt;find / ! \( -name "*yte*" -path "/dev/vg01/*" \) -print&lt;BR /&gt; &lt;BR /&gt;This will ignore any files that have "yte" as part of their name or has a path that starts with "/dev/vg01".&lt;BR /&gt; &lt;BR /&gt;Do not use -a in this case since "!" is a negative it reverses the sense of what's in the parenthesis.&lt;BR /&gt; &lt;BR /&gt;HTH&lt;BR /&gt; &lt;BR /&gt;-- Rod Hills</description>
      <pubDate>Mon, 10 Oct 2005 17:20:32 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/shell-script-to-run-everyday-with-exclusion-mechanism/m-p/3645518#M102331</guid>
      <dc:creator>Rodney Hills</dc:creator>
      <dc:date>2005-10-10T17:20:32Z</dc:date>
    </item>
    <item>
      <title>Re: Shell script to run everyday with Exclusion Mechanism</title>
      <link>https://community.hpe.com/t5/operating-system-linux/shell-script-to-run-everyday-with-exclusion-mechanism/m-p/3645519#M102332</link>
      <description>Henry,&lt;BR /&gt;&lt;BR /&gt;Another approach might be to create a list of directories that you DO want to list.  Create this list in another file.  Then your script can read this file and loop through that list doing your ls -l command.  &lt;BR /&gt;&lt;BR /&gt;In this way, once your script logic is set, you don't have to change it.  You just add or remove directories from your 'directory file'.&lt;BR /&gt;&lt;BR /&gt;Cheers,&lt;BR /&gt;Mark&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 11 Oct 2005 08:29:33 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/shell-script-to-run-everyday-with-exclusion-mechanism/m-p/3645519#M102332</guid>
      <dc:creator>Mark Ellzey</dc:creator>
      <dc:date>2005-10-11T08:29:33Z</dc:date>
    </item>
    <item>
      <title>Re: Shell script to run everyday with Exclusion Mechanism</title>
      <link>https://community.hpe.com/t5/operating-system-linux/shell-script-to-run-everyday-with-exclusion-mechanism/m-p/3645520#M102333</link>
      <description>Hi All&lt;BR /&gt;&lt;BR /&gt;Thanks James,Sandman,Rod &amp;amp; Mark&lt;BR /&gt;&lt;BR /&gt;Mark, &lt;BR /&gt;&lt;BR /&gt;I have question for you,&lt;BR /&gt;can you suggest a mechanism or an approach of how to fit in that file that contains the list of directories that HAVE to be included into my above posted script.&lt;BR /&gt;&lt;BR /&gt;Thanks &lt;BR /&gt;Henry</description>
      <pubDate>Tue, 11 Oct 2005 12:28:51 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/shell-script-to-run-everyday-with-exclusion-mechanism/m-p/3645520#M102333</guid>
      <dc:creator>Henry  Richards</dc:creator>
      <dc:date>2005-10-11T12:28:51Z</dc:date>
    </item>
    <item>
      <title>Re: Shell script to run everyday with Exclusion Mechanism</title>
      <link>https://community.hpe.com/t5/operating-system-linux/shell-script-to-run-everyday-with-exclusion-mechanism/m-p/3645521#M102334</link>
      <description>Hi Henry:&lt;BR /&gt;&lt;BR /&gt;You can do something like this:&lt;BR /&gt;&lt;BR /&gt;...&lt;BR /&gt;while read PATHNAME&lt;BR /&gt;do&lt;BR /&gt;  find ${PATHNMME} ...&lt;BR /&gt;done &amp;lt; your_file_of_directories&lt;BR /&gt;&lt;BR /&gt;Rodneys' suggestion to use the '-path' option to exclude directories is a good one, but it may not be entirely portable.  AIX doesn't allow it and I don't know about Solaris.&lt;BR /&gt;&lt;BR /&gt;You can use '-prune' as an alternative.  It operates OK if you first change directories before your 'find' and thus do something like:&lt;BR /&gt;&lt;BR /&gt;# cd somedirectory&lt;BR /&gt;# find . -name NOTTHIS -prune -o -print&lt;BR /&gt;&lt;BR /&gt;The above would print all files in "somedirectory" except those in the subdirectory "NOTTHIS".&lt;BR /&gt;&lt;BR /&gt;I'm not fully sure what you ultimate goal is here.  If you are trying to track changes in files, then you need to potentially look at more than just file timestamps, sizes and permissions.  Checksum changes would be the next level to track.&lt;BR /&gt;&lt;BR /&gt;If you are really going down that route, a perl program would be a good answer.  Perl has a builtin find() function.  You could couple its use with the stat() function to get the same information 'ls' returns.  Tracking changes could be done with hashes containing the data you want to monitor.&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Tue, 11 Oct 2005 12:55:12 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/shell-script-to-run-everyday-with-exclusion-mechanism/m-p/3645521#M102334</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2005-10-11T12:55:12Z</dc:date>
    </item>
  </channel>
</rss>

