Skip to content

Instantly share code, notes, and snippets.

@aryondev
Created April 5, 2017 12:01
Show Gist options
  • Select an option

  • Save aryondev/e308f176aec31b6c3e60a4b29ff1a317 to your computer and use it in GitHub Desktop.

Select an option

Save aryondev/e308f176aec31b6c3e60a4b29ff1a317 to your computer and use it in GitHub Desktop.
Script for find files with cyrillic texts.
#!/usr/local/bin/perl
use File::Find;
use locale;
use utf8;
my $target_dir = "/path/to/dir";
chomp $target_dir;
my $dir;
my @files;
my $file_path;
find(\&wanted, $target_dir);
foreach $file_path (@files) {
my $content;
$content = do {
local $/ = undef;
open my $fc, "<:encoding(UTF-8)", $file_path
or die "Can't open file :(";
<$fc>;
};
if ($content =~ m/[а-яА-Я]+/i) {
print "\e[91m$file_path \n";
}
};
exit;
sub wanted {
push @files, $File::Find::name;
return;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment