Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/perl
- use strict;
- use warnings;
- use Getopt::Long;
- my $opt_section;
- my $opt_content;
- my $opt_help = 0;
- &GetOptions (
- "help" => $opt_help,
- "section:s" => $opt_section,
- "content:s" => $opt_content,
- );
- if ($opt_help) {
- print "USAGE: file.pl -section <section> -content <content> n ";
- exit;}
- my $dir ="/home/priya/scripts/test/${opt_section}/${opt_content}/latest"; #base directory to look up for the files
- print"$dir n";
- opendir(DIR, $dir) or die "Unable to read Directory : $!";
- while (my $file = readdir(DIR)) {
- #Only files not subdirectories
- next unless (-f "$dir/$file");
- #Use a regular expression to find files ending in .txt
- $file =~ m/^${opt_section}.+txt$/i;
- print "$file n";
- closedir(DIR);
- }
- exit 0;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement