Using Perl One-Liner in macOS to Output File Names and Content with Chinese Characters
In macOS, you can use the following command to output file names and content containing Chinese characters along with line numbers:nnshellnfind /path/to/directory -type f -exec perl -ne 'print "$ARGV: $., $_" if /[x{4e00}-x{9fa5}]/' {} ;nnnReplace /path/to/directory with the path of the directory you want to search.nnThis command uses the find command to locate all files within the specified directory and then uses the perl command to read the file content line by line and match for Chinese characters. If a line contains Chinese characters (matching the Unicode range [x{4e00}-x{9fa5}]), it will output the file name, line number, and line content.nnPlease note that this command will only output lines containing Chinese characters, not the entire file content. If you want to output the entire file content, you can modify the print statement to print "$ARGV: $., $_" if /[x{4e00}-x{9fa5}]/'.
AI 优化版
原文地址:https://www.cveoy.top/t/topic/pQxG 著作权归作者所有。请勿转载和采集!