Use -s test:
#!/bin/perl # To remove all 0 byte file in a folder my $dir = "/home/bob/mytemp"; while (<$dir/*>) {unlink $_ unless (-s)}
Update: first line fixed. When testing I had #!/home/edi/perl but I know our installation is unusual, so I just copied the line from the OP to match his environment .. I thought it looked strange!
I leave the parentheses around conditions deliberately. It helps the less perl-literate of my co-workers.
My solution will only delete files in $dir; in the OP it mentions directory and below. find .. -exec rm is the tool to use in that case.
In reply to Re: Error in script
by GotToBTru
in thread Error in script
by Detox
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |