Perl vs. tcsh?? No contest in this case. The perl version will be a lot easier and make more sense. (Run time is probably not an issue, but I expect it will run faster than the shell script + batch file.)
#!/usr/bin/perl use strict; my %files; # load %files with names of all images on disk for my $disk (qw/F G H/) { if ( open( I, $disk."dir.txt" )) { while (<I>) { next unless ( /_/ ); my $name = "$disk:\\backup\\" . ( split )[4]; $files{$name} = undef; } } else { warn "unable to open dir.txt for $disk: -- $!\n"; next; } } # eliminate hash elements in %files if Netbackup thinks they are on di +sk if ( open( I, "cat.txt" )) { while (<I>) { if ( /([FGH]:\\backup\\)/ ) { my $path = $1; s/\Q$path\E/*/g; my $name = $path . ( split /\*/ )[1]; delete $files{$name}; } } } else { # best to stop here if that last open failed: die "open failed for cat.txt: $!"; } # delete files that are left in the hash unlink for ( keys %files );
(I hoped to say the perl version would be shorter, but that would depend on how you measure script length -- the perl script above is more lines, but fewer characters compared to your shell script, and it does not require the creation of a separate batch file to be run at some other time. And of course, the perl could be shortened to fewer lines.)

In reply to Re: Listing Files in a Directory (Translation From Shell Script) by graff
in thread Listing Files in a Directory (Translation From Shell Script) by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.