How to search files which contain Chinese characters at terminal of Mac?

1k views Asked by At

I have a Vue.js project, there are some resource views containing Chinese characters, I want to find them all from the terminal.

I tried this, but there is no -P for my grep

grep -R -P '[\p{Han}]' resources
2

There are 2 answers

2
Cui Mingda On BEST ANSWER

Found a solution with pcregrep, Chinese is in multiple unicode blocks, so this way is more simple.

pcregrep -r -n '[^\x00-\x7f]' resources
0
cakraww On

Install https://github.com/BurntSushi/ripgrep then

rg '\p{Script=Han}' resources