繼續閱讀

grep: this version of PCRE is not compiled with PCRE_UTF8 support

前言:

         公司伺服器在遷移之後出現了問題,在grep使用正規表達式的時候老是提示grep: this version of PCRE is not compiled with PCRE_UTF8 support,pcre是正規表達式的函數庫,使如果不改正,很煩人。我是源碼安裝的。是以重新編譯的時候加上支援utf-8的選項就可以了。

步驟:

(1)解除安裝prce

       假如是rpm包,直接rpm -qa | grep pcre 或rpm -e pcre --nodeps 就可以了,我這邊用的是源碼包編譯安裝的,使用一下指令進行解除安裝。

[root@rsync pcre]# cd /pcre

[root@rsync pcre]# make uninstall

(2)檢視支援uts-8的可選項是什麼

[root@suzhousl ~]# wget https://sourceforge.net/projects/pcre/files/pcre/8.38/pcre-8.38.tar.bz2/download 
[root@suzhousl ~]# file download 
download: bzip2 compressed data, block size = 900k
[root@hangzhouhl ~]# tar -jxf download 
[root@hangzhouhl ~]# cd pcre-8.38      
[root@rsync pcre]# ./configure --help      
grep: this version of PCRE is not compiled with PCRE_UTF8 support

(3)重新編譯

[root@rsync pcre]# ./configure  --enable-utf8
[root@rsync pcre]# make && make install      

(4)驗證

這是沒加的時候

grep: this version of PCRE is not compiled with PCRE_UTF8 support

這是重新編譯後的,不會再顯示那一行

grep: this version of PCRE is not compiled with PCRE_UTF8 support

(5)但是後來遇到一台伺服器,按這種方法執行以後仍然不能使用,後來把系統語言改為英文之後就可以了,以下是操作。

[root@suzhousl /]# vim /etc/sysconfig/i18n 
LANG="en"