[prog] Perl and find(1)

Akkana Peck akkana at shallowsky.com
Mon Dec 11 04:35:13 UTC 2006


Chris Henderson writes:
> I wrote this script which will go inside some directories and delete
> files but the find(1) command says "-exec" missing. Is it because I'm
> not parsing ls correctly?

It might be confused by having both -print and -exec. That works
here, but it does both: first it prints what it finds, then it
executes the command. Maybe try omitting the -print and see if it
does any better?

	...Akkana

> #!/usr/bin/perl
> 
> use strict;
> use warnings;
> use diagnostics;
> 
> my @directories = qw(
>    /home/backup/server1
>    /home/backup/server2
>    /home/backup/server3
> );
> 
> system "find @directories -atime +14 -name \"*.tgz\" -print -exec ls -al {} 
> \;";

-- 
    ...Akkana
    "Beginning GIMP: From Novice to Professional": http://gimpbook.com


More information about the Programming mailing list