Advertisement
cd62131

grep -l in Perl

Jan 31st, 2019
642
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 0.29 KB | None | 0 0
  1. #!/usr/bin/perl
  2. use strict;
  3. use warnings;
  4. use utf8;
  5. use open qw(:std :encoding(utf8));
  6. my $today = `date +'log/%Y%m%d/*.txt'`;
  7. for my $f (glob $today) {
  8.   open my $in, '<', $f or die;
  9.   while (<$in>) {
  10.     if (/テスト/) {
  11.       print "$f\n";
  12.       last;
  13.     }
  14.   }
  15.   close $in;
  16. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement