perl - grep any non-keyboard character -


i'm downloading bibtex entries, there random characters not show in output pdf, e.g. àèìòùáéíóúäëïöüâêîôûÿøÀÈÌÒÙÁÉÍÓÚÄËÏÖÜ list isn't comprehensive (random foreign letters cannot type).

i've tried things

grep -np '[^a-za-z0-9\/,=!@#$%^&*()_]' ~/documents/library.bib 

but there has got easier way this.

how can grep or use perl regex character cannot type on keyboard (is ascii too?) e.g. if have "n" accent there way can know that?

you can use posix character class [:ascii:] matches character in ascii character set. print lines non ascii characters:

grep -np '[^[:ascii:]]' ~/documents/library.bib 

or, highlight non-ascii characters:

grep --color=auto -np '[^[:ascii:]]' ~/documents/library.bib 

see character classes , bracket expressions in gnu grep manual , posix bracket expressions @ regular-expression.info more information.

see also: how grep non-ascii characters in unix


Comments