<?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: Perl script to delete older files in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/perl-script-to-delete-older-files/m-p/5119755#M687084</link>
    <description>Well as i said i m a rookie...:) thanks!</description>
    <pubDate>Wed, 16 Jul 2008 15:48:33 GMT</pubDate>
    <dc:creator>Krisklan</dc:creator>
    <dc:date>2008-07-16T15:48:33Z</dc:date>
    <item>
      <title>Perl script to delete older files</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/perl-script-to-delete-older-files/m-p/5119752#M687081</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;I am new to scripting. I am using the command &lt;BR /&gt;find /tmp/histdwn/h0* -type f -mtime +30 -exec rm {} \;  to delete files older than 30 days. The command works well on command line on HPUX.&lt;BR /&gt;&lt;BR /&gt;But when I use the same code in a perl script.&lt;BR /&gt;&lt;BR /&gt;#!/opt/OV/contrib/perl/bin/perl&lt;BR /&gt;find /tmp/histdwn/h0* -type f -mtime +28 -exec rm {} \;&lt;BR /&gt;&lt;BR /&gt;The error I get is:&lt;BR /&gt;&lt;BR /&gt;Backslash found where operator expected at ./hist.pl line 2, near "} \"&lt;BR /&gt;        (Missing operator before  \?)&lt;BR /&gt;syntax error at ./hist.pl line 9, near "} \"&lt;BR /&gt;Execution of ./hist.pl aborted due to compilation errors.&lt;BR /&gt;&lt;BR /&gt;Please correct this. Thanks!&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Wed, 16 Jul 2008 15:26:59 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/perl-script-to-delete-older-files/m-p/5119752#M687081</guid>
      <dc:creator>Krisklan</dc:creator>
      <dc:date>2008-07-16T15:26:59Z</dc:date>
    </item>
    <item>
      <title>Re: Perl script to delete older files</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/perl-script-to-delete-older-files/m-p/5119753#M687082</link>
      <description>You are trying to use PERL to run a shell command.  That won't work, as you have found.&lt;BR /&gt;&lt;BR /&gt;The easiest way is not to use PERL at all.  Create your script as a regular shell script.&lt;BR /&gt;&lt;BR /&gt;# cat my-script&lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt;find /tmp/histdwn/h0* -type f -mtime +28 -exec rm {} \;&lt;BR /&gt;&lt;BR /&gt;Now give yourself permissions to run it and you should be fine.</description>
      <pubDate>Wed, 16 Jul 2008 15:44:10 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/perl-script-to-delete-older-files/m-p/5119753#M687082</guid>
      <dc:creator>Patrick Wallek</dc:creator>
      <dc:date>2008-07-16T15:44:10Z</dc:date>
    </item>
    <item>
      <title>Re: Perl script to delete older files</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/perl-script-to-delete-older-files/m-p/5119754#M687083</link>
      <description>Cannot do this the way you are trying.&lt;BR /&gt;&lt;BR /&gt;You can call shell commands from a perl script but not in the direct fashion as you have.&lt;BR /&gt;&lt;BR /&gt;Not sure why you need to use perl to do this but Perl could provide another methods as well.  unfortunately I am not a perl guru.. &lt;BR /&gt;&lt;BR /&gt;Need to wait until the perl gurus chime in.&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Wed, 16 Jul 2008 15:44:25 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/perl-script-to-delete-older-files/m-p/5119754#M687083</guid>
      <dc:creator>Tim Nelson</dc:creator>
      <dc:date>2008-07-16T15:44:25Z</dc:date>
    </item>
    <item>
      <title>Re: Perl script to delete older files</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/perl-script-to-delete-older-files/m-p/5119755#M687084</link>
      <description>Well as i said i m a rookie...:) thanks!</description>
      <pubDate>Wed, 16 Jul 2008 15:48:33 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/perl-script-to-delete-older-files/m-p/5119755#M687084</guid>
      <dc:creator>Krisklan</dc:creator>
      <dc:date>2008-07-16T15:48:33Z</dc:date>
    </item>
    <item>
      <title>Re: Perl script to delete older files</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/perl-script-to-delete-older-files/m-p/5119756#M687085</link>
      <description>Hi:&lt;BR /&gt;&lt;BR /&gt;Your syntax is fine for a shell but for a Perl script, you should do:&lt;BR /&gt;&lt;BR /&gt;# perl -MFile::Find -le 'find(sub{unlink $File::Find::name if -f $_ &amp;amp;&amp;amp; -M _ &amp;gt;= 28},@ARGV)' /path&lt;BR /&gt;&lt;BR /&gt;To match filenames containing "h0", do something like:&lt;BR /&gt;&lt;BR /&gt;perl -MFile::Find -le 'find(sub{print $File::Find::name if -f $_ &amp;amp;&amp;amp; -M _ &amp;gt;= 6000 &amp;amp;&amp;amp; m{h0}},@ARGV)' /path&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...&lt;BR /&gt;</description>
      <pubDate>Wed, 16 Jul 2008 15:57:20 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/perl-script-to-delete-older-files/m-p/5119756#M687085</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2008-07-16T15:57:20Z</dc:date>
    </item>
    <item>
      <title>Re: Perl script to delete older files</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/perl-script-to-delete-older-files/m-p/5119757#M687086</link>
      <description>&amp;gt;find /tmp/histdwn/h0* -type f -mtime +28 -exec rm {} \;&lt;BR /&gt;&lt;BR /&gt;If you want better performance in find, replace that ";" by a +:&lt;BR /&gt;find ... -exec rm {} +</description>
      <pubDate>Wed, 16 Jul 2008 17:41:48 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/perl-script-to-delete-older-files/m-p/5119757#M687086</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2008-07-16T17:41:48Z</dc:date>
    </item>
    <item>
      <title>Re: Perl script to delete older files</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/perl-script-to-delete-older-files/m-p/5119758#M687087</link>
      <description>Hi (again):&lt;BR /&gt;&lt;BR /&gt;My second example, adding matching for specific filenames, neglected to change the 'print' to 'unlink' and set the number of days too high.  I meant to write:&lt;BR /&gt;&lt;BR /&gt;# To match filenames containing "h0", do something like:&lt;BR /&gt;&lt;BR /&gt;perl -MFile::Find -le 'find(sub{unlink $File::Find::name if -f $_ &amp;amp;&amp;amp; -M _ &amp;gt;= 28 &amp;amp;&amp;amp; m{h0}},@ARGV)' /path&lt;BR /&gt;&lt;BR /&gt;As you can see, the code can be tested by changing 'unlink' (the system call for 'rm') to 'print'.&lt;BR /&gt;&lt;BR /&gt;Note too, that you can pass multiple '/path' arguments to the script if you want to examine multiple directories.&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...&lt;BR /&gt;</description>
      <pubDate>Thu, 17 Jul 2008 11:24:02 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/perl-script-to-delete-older-files/m-p/5119758#M687087</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2008-07-17T11:24:02Z</dc:date>
    </item>
  </channel>
</rss>

