in reply to UNIX command - remove 0 byte file

Hello All!

I am also confused. 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.

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"; </P

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^2: UNIX command - remove 0 byte file
by Anonymous Monk on Aug 17, 2011 at 05:26 UTC