Re: change to a shell to Perl

Herbert wrote:
> find ${i} -mtime +30 -type f -print0 | xargs -0 compress -vf
> find ${i} -mtime +180 -type f -print0 | xargs -0 rm -vf
> Is ther any way to make two find command lines one using perl?

Yes, but I'm not sure you really gain anything by doing so. "find"
operations in Perl are the same as in bash - a single command (with
whatever parameters) returns a single list of files. Combining the
finds will return a list comprised of files meeting two different sets
of criteria, so you would need to sub-process this list to tell which
files are compressed and which are deleted.

For example, you could do a single "find" for all files older than 30
days and then do a conditional (if) to re-check the timestamp and
process it according to your criteria (delete if older than 180 days,
else compress it), but I would personally prefer two find operations.


Relevant Pages

  • Re: Wait for background processes to complete
    ... To be able to execute commands in the background and wait for their ... The documentation I am referring to is ... You can run a command in the background with: ... There is a general problem with perl documentation: ...
  • Re: Perl For Amateur Computer Programmers
    ... >professional computer programmers could use with the same ease as Basic. ... >Perl For Amateur Computer Programmers ... Also, taking into account that you're appealing to "scientists", it ... Also, as a side note, you seem to use the noun "command" in a naive ...
  • Obtaining complete Unix command line that evoked script as string
    ... If there is a more appropriate list for this, let me know; the other perl lists I've seen seem to specialised for this. ... Note this is not just the arguments of the call to the script, but everything including pipes and redirects, etc., e.g. ... Ideally the perl interpreter would grab the complete command line as its evoked and I'd access this via a variable. ...
  • Re: How to process multi-line records ?
    ... > DataField1: ... > do this in Perl. ... > conditional to determine if that record meets the desired criteria. ... > Thanks in advance for any help and/or hints. ...
  • Re: CLOSING Re: Obtaining complete Unix command line that evoked script as string
    ... > To: Grant Jacobs; beginners perl ... > perl and less, much less passing that information along to either ... Only shell that launched them is keeping track of the I/O ... > command is executed. ...