grep/regex can't find accented word

后端 未结 5 2007
抹茶落季
抹茶落季 2021-01-18 20:41

I\'m trying mount a regex that get some words on a file where all letters of this word match with a word pattern.

My problem is, the regex can\'t find accented words

5条回答
  •  终归单人心
    2021-01-18 21:18

    If your file is encoded in ISO-8859-1 but your system locale is UTF-8, this will not work.

    Either convert the file to UTF-8 or change your system locale to ISO-8859-1.

    # convert from ISO-8859-1 to the environmental locale before grepping
    # output will be in the current locale
    $ iconv -f 8859_1 input/words.txt | grep ...
    
    # run grep with an ISO-8859-1 locale
    # output will be in ISO-8859-1 encoding
    $ cat input/words.txt | env LC_ALL=en_US grep ...
    

提交回复
热议问题