处理文件中的" M-BM- "特殊符号
有时为了方便,会在Excel中进行代码拼装,比如说是建表SQL语句,但是在复制的代码过程中可能会带入不可见字符,造成代码无法运行。
本次代码中就需要了不可见的" M-BM- "
- 问题现象
hive 执行报错 
FAILED: ParseException line 5:5 character ' ' not supported here
- 代码段
单纯看无异样 
,area                 array<string>      comment '常驻城市'
,brand                array<string>      comment '手机品牌'
,model                array<string>      comment '手机型号'
,price                array<string>      comment '手机价格'
- 使用
cat -A查看
就发现问题所在了 
,areaM-BM-  M-BM-  M-BM-  M-BM-  M-BM-  M-BM-  M-BM-  M-BM-   array<string>      comment 'M-eM-8M-8M-iM-)M-;M-eM-^_M-^NM-eM-8M-^B'$
,brand M-BM-  M-BM-  M-BM-  M-BM-  M-BM-  M-BM-  M-BM-   array<string>      comment 'M-fM-^IM-^KM-fM-^\M-:M-eM-^SM-^AM-gM-^IM-^L'$
,model M-BM-  M-BM-  M-BM-  M-BM-  M-BM-  M-BM-  M-BM-   array<string>      comment 'M-fM-^IM-^KM-fM-^\M-:M-eM-^^M-^KM-eM-^OM-7'$
- 解决方案
参考此文使用sed进行替换 
sed -i 's/\xc2\xa0/ /g' myscript.sql
--EOF--
                    
                
                
            
        
浙公网安备 33010602011771号