Detox has asked for the wisdom of the Perl Monks concerning the following question:
I am confused. I found a possible solution to finding / deleting zero byte files. Here is the excerpt from the post I would like to discuss is:
If you need to do it from a Perl program, I would do:
# Remove all empty files in '$dir' and below. </p> my $dir = "/some/path"; system "find '$dir' -size 0c | xargs rm";
To write a perl script to make this work, it would look like:
!#/bin/perl # To remove all 0 byte file in a folder my $dir = "/home/bob/mytemp"; system "find '$dir' -size 0c | xargs rm";
This does not work. I can type this from command line:
find . -type f -size 0 | xargs rm
and it deletes all zero byte file.
I can type from cmd line:
find /home/bob/mytemp -type f -size 0 -exec rm {} \;
and it removes all 0 byte file.
BUT,,, when I put it in a perl script, it errors or just does not work.
Can anyone explain why?
Thanks so much
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Error in script
by Perlbotics (Archbishop) on Aug 15, 2011 at 15:30 UTC | |
|
Re: Error in script
by toolic (Bishop) on Aug 15, 2011 at 15:15 UTC | |
|
Re: Error in script
by GotToBTru (Prior) on Aug 15, 2011 at 16:21 UTC | |
by raybies (Chaplain) on Aug 15, 2011 at 16:42 UTC | |
|
Re: Error in script
by hbm (Hermit) on Aug 15, 2011 at 15:12 UTC |