in reply to delete all directories which are not in list
Here's one way of doing it:
#!/usr/bin/perl -w use strict; chdir('dir1'); open(my $fh, '<', 'list.name') or die("open() failed: $!"); my %all = map { $_ => undef } grep { -d } glob("*"); delete($all{$_}) for ( map { chomp; split(/,/, $_) } <$fh> ); system('rm', '-ir', $_) for (keys(%all)); __END__ format of dir1/list.name: dir1,dir2,dir3,dir4,etc dir10,dir11, dir12,dir_x
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: delete all directories which are not in list
by Anonymous Monk on Feb 10, 2005 at 07:13 UTC | |
by saskaqueer (Friar) on Feb 11, 2005 at 03:54 UTC |