Created
April 5, 2017 12:01
-
-
Save aryondev/e308f176aec31b6c3e60a4b29ff1a317 to your computer and use it in GitHub Desktop.
Script for find files with cyrillic texts.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/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