This little snippit cleaned out the files. The syntax is:
anti-tar tarfile
Execute it from the base directory you errantly untarred the file into. It will grab the listing of files and dirs from the tar file and remove them from the current directory and subsequent subdirs as needed. It takes advantage of rmdir's severe reluctance to blow away non-empty subdirs.
USE WITH CARE! YMMV!
#!/usr/bin/perl -w use strict; use Archive::Tar; die "Provide the name of the tar file, please!\n" unless $ARGV[0]; my $tar = Archive::Tar->new(); $tar->read( $ARGV[0], 0 ); @_ = $tar->list_files(); my @files = sort { $b cmp $a } @_; foreach ( @files ) { if ( -d ) { rmdir or warn "$_ is not empty (sharred path)\n"; next; } unlink; }
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: anti-tar - remove mis-extracted files and dirs
by fundflow (Chaplain) on Aug 30, 2001 at 15:07 UTC |