perl - grep filename in directory -


i have directory named - "requests" inside have below files

 transition-request-201405061735.html  requisition-request-201405061735.html  transition-request-201405061735.txt  transition-request-201405061735.csv  output.txt 

i need filter transition-request-201405061735.txt

the code came far below

 #!/usr/bin/perl  use strict;  use warnings;     $request = "/tmp/requests";    opendir(dir, $request) or die $!;     @inputfiles = grep { /ion-request-/ && \/\.txt$/ && -f "$request/$_"  } readdir(dir);    print "@inputfiles\n"; 

output below

transition-request-201405061735.html transition-request-201405061735.csv transition-request-201405061735.txt requisition-request-201405061735.html 

i seeking experts advise in using valid grep statement filter desired file - transition-request-201405061735.txt

this due escape character:

  \/\.txt$/ # ^ here 

just remove it:

.... /ion-request-/ && /\.txt$/ ... 

Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

ios - Change Storyboard View using Seague -