免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 475 | 回复: 0

[文本处理] 如何去掉 ^M和连续空格合并成一行 [复制链接]

论坛徽章:
0
发表于 2019-07-31 09:46 |显示全部楼层
原内容:

update weather set `weather_data`='{"city":"连云港","updatetime":"00:39","wendu":"27","fengli":"1级","shidu":"92%","fengxiang":"西南风","sunrise_1":"05:07","sunset_1":"19:11","sunrise_2":{},"sunset_2":{},"yesterday":{"date_1":"24日星期三","high_1":"高温 33℃","low_1":"低温 27℃","day_1":{"type_1":"雷阵雨","fx_1":"西南>风","fl_1":"<3级"},"night_1":{"type_1":"雷阵雨","fx_1":"西南风","fl_1":"<3级"}},"forecast":{"weather":[{"date":"25日星期四","high":"高温 33℃","low":"低温 27℃","day":{"type":"雷阵雨","fengxiang":"西南风","fengli":"<3级"},"night":{"type":"雷阵雨","fengxiang":"南风","fengli":"<3级"}},{"date":"26日星期五","high":"高温 33℃","low":"低温 26℃","day":{"type":"雷阵雨","fengxiang":"南风","fengli":"<3级"},"night":{"type":"雷阵雨","fengxiang":"南风","fengli":"<3级"}},{"date":"27日星期>六","high":"高温 31℃","low":"低温 26℃","day":{"type":"雷阵雨","fengxiang":"南风","fengli":"<3级"},"night":{"type":"雷阵雨","fengxiang":"南风","fengli":"<3级"}},{"date":"28日星期天","high":"高温 31℃","low":"低温 26℃","day":{"type":"雷阵雨","fengxiang":"东南风","fengli":"<3级"},"night":{"type":"多云","fengxiang":"南风","fengli":"3-4级"}},{"date":"29日星期一","high":"高温 34℃","low":"低温 28℃","day":{"type":"多云","fengxiang":"南风","fengli":"3-4级"},"night":{"type":"多云","fengxiang":"南风","fengli":"3-4级"}}]},"zhishus":{"zhishu":[{"name":"晨练指数","value":"较不宜","detail":"有降水,较不宜晨练,室外锻炼请携带雨具。建议年老体弱人
群适当减少晨练时间。"},{"name":"舒适度","value":"较不舒适","detail":"白天虽然有雨,但仍无法削弱较高气温带来的暑意,同时降雨造成湿度加大会您感到有些闷热,不很舒
适。"},{"name":"穿衣指数","value":"炎热","detail":"天气炎热,建议着短衫、短裙、短裤、薄型T恤衫等清凉夏季服装。"},{"name":"感冒指数","value":"少发","detail":"各
项气象条件适宜,发生感冒机率较低。但请避免长期处于空调房间中,以防感冒。"},{"name":"晾晒指数","value":"不宜","detail":"有降水,不适宜晾晒。若需要晾晒,请在室内
准备出充足的空间。"},{"name":"旅游指数","value":"一般","detail":"较热,微风,有降水,请尽量不要外出,若外出,请注意防雷并携带雨具,注意防暑降温。"},{"name":"紫
外线强度","value":"中等","detail":"属中等强度紫外线辐射天气,外出时建议涂擦SPF高于15、PA+的防晒护肤品,戴帽子、太阳镜。"},{"name":"洗车指数","value":"不宜","detail":"不宜洗车,未来24小时内有雨,如果在此期间洗车,雨水和路上的泥水可能会再次弄脏您的爱车。"},{"name":"运动指数","value":"较不宜","detail":"有降水,推荐您在>室内进行低强度运动;若坚持户外运动,须注意选择避雨防滑地点,并携带雨具。"},{"name":"约会指数","value":"较不适宜","detail":"虽然有风,但天气较热,且有时有降水,
外出约会请选择荫凉地点并做好防雨工作。"},{"name":"雨伞指数","value":"带伞","detail":"有降水,如果您要短时间外出的话可不必带雨伞。"}]}}',`aqi`='23',`aqi_data`='{"status": "0","city": "连云港","cityid": "101191001","en": "AQI","cn": "空气质量指数","val": "23","lev": "优",^M
"impx": "空气质量令人满意,基本无空气污染",^M

"advc": "各类人群可正常活动","data": [{"en": "PM2.5","cn": "细颗粒物","val": "16"},{"en": "NO2","cn": "二氧化氮","val": "14"},{"en": "CO","cn": "一氧化碳","val": "0.6"},{"en": "O3","cn": "臭氧","val": "56"},{"en": "SO2","cn": "二氧化硫","val": "5"},{"en": "PM10","cn": "可吸入颗粒物","val": "6"}],"updata": "201907242300"}' where id='312'
/*!*/;




红色部份导致sql被分隔为三行了, 而这个^M  要用  CTRL +V+M 来生成是一个特殊的符号
现在就想用shell 把 ^M+多个空格 去掉,

我用 sed "s/^M \+//g"   只去了 ^M没去掉空格,奇怪。


您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

SACC2019中国系统架构师大会

【数字转型 架构演进】SACC2019中国系统架构师大会,7折限时优惠重磅来袭!
2019年10月31日~11月2日第11届中国系统架构师大会(SACC2019)将在北京隆重召开。四大主线并行的演讲模式,1个主会场、20个技术专场、超千人参与的会议规模,100+来自互联网、金融、制造业、电商等领域的嘉宾阵容,将为广大参会者提供一场最具价值的技术交流盛会。

限时七折期:2019年8月31日前


----------------------------------------

大会官网>>
  

北京盛拓优讯信息技术有限公司. 版权所有 16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122
中国互联网协会会员  联系我们:huangweiwei@it168.com
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP