Search code examples
macosshellunicodeterminalgrep

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


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

Solution

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

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