<?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: simple rm script in Operating System - Linux</title>
    <link>https://community.hpe.com/t5/operating-system-linux/simple-rm-script/m-p/3886567#M99138</link>
    <description>Hi,&lt;BR /&gt;simply add in your crontab the command:&lt;BR /&gt;&lt;BR /&gt;cd &lt;YOUR_DIR&gt; &amp;amp;&amp;amp; /usr/bin/rm *.txt&lt;BR /&gt;&lt;BR /&gt;at more conveninet time for you.&lt;BR /&gt;&lt;BR /&gt;HTH,&lt;BR /&gt;Art&lt;/YOUR_DIR&gt;</description>
    <pubDate>Thu, 26 Oct 2006 03:24:33 GMT</pubDate>
    <dc:creator>Arturo Galbiati</dc:creator>
    <dc:date>2006-10-26T03:24:33Z</dc:date>
    <item>
      <title>simple rm script</title>
      <link>https://community.hpe.com/t5/operating-system-linux/simple-rm-script/m-p/3886558#M99129</link>
      <description>I need to rm all txt files in a certain dir every night.  Can you give me some suggestions on how to do this?</description>
      <pubDate>Wed, 25 Oct 2006 12:12:20 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/simple-rm-script/m-p/3886558#M99129</guid>
      <dc:creator>Tamera Street</dc:creator>
      <dc:date>2006-10-25T12:12:20Z</dc:date>
    </item>
    <item>
      <title>Re: simple rm script</title>
      <link>https://community.hpe.com/t5/operating-system-linux/simple-rm-script/m-p/3886559#M99130</link>
      <description>rm *.txt</description>
      <pubDate>Wed, 25 Oct 2006 12:14:59 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/simple-rm-script/m-p/3886559#M99130</guid>
      <dc:creator>David Bellamy</dc:creator>
      <dc:date>2006-10-25T12:14:59Z</dc:date>
    </item>
    <item>
      <title>Re: simple rm script</title>
      <link>https://community.hpe.com/t5/operating-system-linux/simple-rm-script/m-p/3886560#M99131</link>
      <description>Hi Tamera:&lt;BR /&gt;&lt;BR /&gt;Please define what you mean by "txt" --- an extension to a filename?  --- an ASCII file as opposed to a binary one?&lt;BR /&gt;&lt;BR /&gt;Do you want to recursively descend a directory?&lt;BR /&gt;&lt;BR /&gt;Do you need help with the process of selecting and removing?  Do you need help setting up a 'crontab'?&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Wed, 25 Oct 2006 12:19:52 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/simple-rm-script/m-p/3886560#M99131</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2006-10-25T12:19:52Z</dc:date>
    </item>
    <item>
      <title>Re: simple rm script</title>
      <link>https://community.hpe.com/t5/operating-system-linux/simple-rm-script/m-p/3886561#M99132</link>
      <description>Friend &lt;BR /&gt;&lt;BR /&gt;Script follows one that and safer than to execute rm *.txt :&lt;BR /&gt;&lt;BR /&gt;for G in `ll |grep .sh |awk '{print $9}'`&lt;BR /&gt;do&lt;BR /&gt;rm $G&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Wed, 25 Oct 2006 12:40:35 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/simple-rm-script/m-p/3886561#M99132</guid>
      <dc:creator>Calandrello</dc:creator>
      <dc:date>2006-10-25T12:40:35Z</dc:date>
    </item>
    <item>
      <title>Re: simple rm script</title>
      <link>https://community.hpe.com/t5/operating-system-linux/simple-rm-script/m-p/3886562#M99133</link>
      <description>Hi Tamera,&lt;BR /&gt;&lt;BR /&gt;In this example, a cron job, which will be run as root, is scheduled.  The job deletes all .txt files in /yourdir and its subdirectories at 11:00pm every day.&lt;BR /&gt;&lt;BR /&gt;# grep -q root /var/adm/cron/cron.allow || echo root &amp;gt;&amp;gt; /var/adm/cron/cron.allow&lt;BR /&gt;# crontab -l root &amp;gt; /tmp/crontab.root&lt;BR /&gt;# echo "00 23 * * * find /yourdir -name '*.txt' -type f -exec rm -f {} 1&amp;gt; /dev/null \;" &amp;gt;&amp;gt; /tmp/crontab.root&lt;BR /&gt;# crontab &amp;lt; /tmp/crontab.root&lt;BR /&gt;# rm -f /tmp/crontab.root&lt;BR /&gt;&lt;BR /&gt;For obvious reasons, care must be taken with a job such as this.&lt;BR /&gt;&lt;BR /&gt;PCS</description>
      <pubDate>Wed, 25 Oct 2006 12:46:17 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/simple-rm-script/m-p/3886562#M99133</guid>
      <dc:creator>spex</dc:creator>
      <dc:date>2006-10-25T12:46:17Z</dc:date>
    </item>
    <item>
      <title>Re: simple rm script</title>
      <link>https://community.hpe.com/t5/operating-system-linux/simple-rm-script/m-p/3886563#M99134</link>
      <description>&amp;gt;Calandrello Script follows one that and safer than to execute rm *.txt&lt;BR /&gt;&lt;BR /&gt;I'm not sure how this is safer or how it is "txt"?  Also did you want to escape the "."?&lt;BR /&gt;&lt;BR /&gt;But you can improve your script:&lt;BR /&gt;for G in $(ls | fgrep .sh); do rm $G; done&lt;BR /&gt;But this is the same as: rm *.sh.&lt;BR /&gt;Unless you really wanted to remove *.sh* files?&lt;BR /&gt;&lt;BR /&gt;&amp;gt;spex&lt;BR /&gt;00 23 * * * find /yourdir -name '*.txt' -type f -exec rm -f {} 1&amp;gt; /dev/null \;&lt;BR /&gt;&lt;BR /&gt;Any reason you want to redirect stdout from the rm command?  You don't get anything, only to stderr.  Did you mean "2&amp;gt;"?</description>
      <pubDate>Wed, 25 Oct 2006 14:23:20 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/simple-rm-script/m-p/3886563#M99134</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2006-10-25T14:23:20Z</dc:date>
    </item>
    <item>
      <title>Re: simple rm script</title>
      <link>https://community.hpe.com/t5/operating-system-linux/simple-rm-script/m-p/3886564#M99135</link>
      <description>The txt is a extension - data.txt  I know how to do this by command line everyday but my scripting is limited.  I would like to put this in a crontab to run everynight.</description>
      <pubDate>Wed, 25 Oct 2006 14:27:18 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/simple-rm-script/m-p/3886564#M99135</guid>
      <dc:creator>Tamera Street</dc:creator>
      <dc:date>2006-10-25T14:27:18Z</dc:date>
    </item>
    <item>
      <title>Re: simple rm script</title>
      <link>https://community.hpe.com/t5/operating-system-linux/simple-rm-script/m-p/3886565#M99136</link>
      <description>Scripting is no different than typing the command(s) interactively. If you type one command such as:&lt;BR /&gt; &lt;BR /&gt;rm /var/tmp/specialdir/*.txt&lt;BR /&gt; &lt;BR /&gt;then you simply add that to crontab and pick a time at night to run this command. If there are multiple commands needed, put them into a file, add an interpreter line at the top and make it executable. Then add the full path to the script to crontab. Something like this:&lt;BR /&gt; &lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt;rm /var/tmp/specialdir1/*.txt&lt;BR /&gt;rm /var/tmp/specialdir2/*.txt&lt;BR /&gt;rm /var/tmp/specialdir3/*.txt&lt;BR /&gt;</description>
      <pubDate>Wed, 25 Oct 2006 20:34:47 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/simple-rm-script/m-p/3886565#M99136</guid>
      <dc:creator>Bill Hassell</dc:creator>
      <dc:date>2006-10-25T20:34:47Z</dc:date>
    </item>
    <item>
      <title>Re: simple rm script</title>
      <link>https://community.hpe.com/t5/operating-system-linux/simple-rm-script/m-p/3886566#M99137</link>
      <description>Tamara,&lt;BR /&gt;For me rm is rather silent.&lt;BR /&gt;&lt;BR /&gt;I would prefer to embedd the rm command inside a find and log this. This would&lt;BR /&gt;improve security and visability.&lt;BR /&gt;&lt;BR /&gt;The crontab entry would look like this:&lt;BR /&gt;(10 minutes before midnight, every day of the week)&lt;BR /&gt;&lt;BR /&gt;50  23 * * * /root/adm/bin/text_clean.sh &amp;gt; /root/adm/logs/text_clean.log 2&amp;gt;&amp;amp;1&lt;BR /&gt;&lt;BR /&gt;The script would look like this:&lt;BR /&gt;vi text_clean.sh&lt;BR /&gt;&lt;BR /&gt;#!/sbin/sh&lt;BR /&gt;# Script to clean txt files by Tamara&lt;BR /&gt;&lt;BR /&gt;find /path/textfiles -name "*txt" -type f -print -exec rm {} \;&lt;BR /&gt;&lt;BR /&gt;#end of script&lt;BR /&gt;&lt;BR /&gt;Now you could at a later stage , put a time&lt;BR /&gt;criteria in your find. For example to delete only the *.txt files older then 1 day.&lt;BR /&gt;The find command would look like this:&lt;BR /&gt;&lt;BR /&gt;find /path/textfiles -name "*txt" -type f -mtime +1 -print -exec rm {} \;&lt;BR /&gt;&lt;BR /&gt;You can also put multiple find commands in the script. So your housekeeping collection&lt;BR /&gt;can grow over time as the need arises.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 26 Oct 2006 02:19:21 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/simple-rm-script/m-p/3886566#M99137</guid>
      <dc:creator>Frank de Vries</dc:creator>
      <dc:date>2006-10-26T02:19:21Z</dc:date>
    </item>
    <item>
      <title>Re: simple rm script</title>
      <link>https://community.hpe.com/t5/operating-system-linux/simple-rm-script/m-p/3886567#M99138</link>
      <description>Hi,&lt;BR /&gt;simply add in your crontab the command:&lt;BR /&gt;&lt;BR /&gt;cd &lt;YOUR_DIR&gt; &amp;amp;&amp;amp; /usr/bin/rm *.txt&lt;BR /&gt;&lt;BR /&gt;at more conveninet time for you.&lt;BR /&gt;&lt;BR /&gt;HTH,&lt;BR /&gt;Art&lt;/YOUR_DIR&gt;</description>
      <pubDate>Thu, 26 Oct 2006 03:24:33 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/simple-rm-script/m-p/3886567#M99138</guid>
      <dc:creator>Arturo Galbiati</dc:creator>
      <dc:date>2006-10-26T03:24:33Z</dc:date>
    </item>
  </channel>
</rss>

