App-rmhere

 view release on metacpan or  search on metacpan

script/rmhere  view on Meta::CPAN

#!perl

our $DATE = '2017-07-07'; # DATE
our $VERSION = '0.08'; # VERSION

use 5.010001;
use strict;
use warnings;

use Perinci::CmdLine::Any;
Perinci::CmdLine::Any->new(url => '/App/rmhere/rmhere')->run;

1;
# ABSTRACT: Delete files in current directory
# PODNAME: rmhere

__END__

=pod

=encoding UTF-8

=head1 NAME

rmhere - Delete files in current directory

=head1 VERSION

This document describes version 0.08 of rmhere (from Perl distribution App-rmhere), released on 2017-07-07.

=head1 SYNOPSIS

In a directory with many files which you want to delete:

 % rmhere -f

To show progress:

 % rmhere -fp

To show progress and count the number of files first (so it'll show percentage
up to 100% and estimated completion time):

 % rmhere -fP

Delete recursively, set location:

 % rmhere -Rf --here /tmp/files

Don't actually delete files, only show:

 % rmhere -f --dry-run

Only delete files matching a wildcard:

 % rmhere --nodir -R --match '*.txt'

=head1 DESCRIPTION

NOTE: Early release, some options not yet implemented: --dir, --file, --match,
--recursive.

When deleting many files in a directory (thousands, millions), the venerable
L<rm> Unix command is rather cumbersome to use. If you issue C<rm *> the shell
will usually complain with "Argument list too long" because it expands the
wildcard first. You can also use C<< find ./ -type f -maxdepth 1 -delete >>.
This B<rmhere> command is equivalent to that, with some extra options and
features:

=over

=item * Progress report

=item * Dry-run

Just set DRY_RUN=1 or C<--dry-run> to enter dry-run (simulation) mode.

=item * Recursive option

Using C<-R>.

=back

For safety, the default behavior is C<-i>. That means, if B<rmhere> is executed
without argument, it will ask before deleting each file.

=head1 PERFORMANCE NOTES

My system: customer SATA HDD 7200rpm, Debian/Linux, ext3fs, Core i5-2400 3.1GHz.
B<rmhere> performs worse than B<rm> for small to medium number of files (1-200k
files), but as the number of files approaches 1+ million, there are practically
no difference in performance as the bottleneck lies in the filesystem. Some
numbers:

Creating 200k files using C<< touch `seq 1 200000` >>: 5s.

Deleting 200k files using C<< rm >>: 6s.

Deleting 200k files using C<< rmhere -fP >>: 1m10s.

Creating 1 million files using C<< touch `seq 1 200000`;touch `seq 200001



( run in 0.703 second using v1.01-cache-2.11-cpan-39bf76dae61 )