尝试从MacOS bash shell中的大文件中提取非英语字符时出现“非法字节序列”错误。 这是我尝试使用的脚本:
sed 's/[][a-z,0-9,A-Z,!@#\$%^&*(){}":/_-|. -][\;''=?]*//g' < $1 >Abhineet_extract1.txt;
sed 's/\(.\)/\1\
/g' <Abhineet_extract1.txt | sort | uniq |tr -d '\n' >&1;
rm Abhineet_extract1.txt;
这是我得到的错误:
uniq: stdin: Illegal byte sequence
'+?
答案 0 :(得分:12)
似乎UTF-8语言环境导致Illegal byte sequence
。
相反说:
LC_CTYPE=C your_command
man locale
说:
These environment variables affect each locale categories for all
locale-aware programs:
LC_CTYPE
Character classification and case conversion.