Find unicode characters in file

Find unicode or non-ascii characters using grep.

$ cat myfile.txt 
Lorem
ipsūm
dolor
sit
amet,
pōnderum
tritani
onstituto
in
duo.

Find line numbers

$ grep --line-number --perl-regexp '[^\x00-\x7F]+' myfile.txt 
2:ipsūm
6:pōnderum

Find characters

$ grep --line-number --only-matching --perl-regexp '[^\x00-\x7F]+' myfile.txt 
2
6

Use grep to find unicode characters

$ grep "$(printf %b '\u2013')" myfile.txt

Find unicode characters in vim

/\%u2013
View this page on GitHub.
Posted .

Comments

Leave a Reply