提问人:Colin Hay 提问时间:12/6/2019 最后编辑:Colin Hay 更新时间:12/9/2019 访问量:420
在 LInux Suse 12 上使用 sed 将 unix 中的智能引号替换为单引号
Replacing smart quotes in unix with single quotes using sed on LInux Suse 12
问:
如果我以普通用户身份运行它
#!/bin/bash
echo This is a smart quote â fixed using previous method | sed "s/â/'/g"
QUOTES="\xE2\x80\x9C|\xE2\x80\x9D"
echo This is a fixed smart quote â fixed using new method | sed "s/[$QUOTES]/'/g"
在提示符下按预期运行脚本时,使用任一方法替换智能引号
如果我将脚本作为 cron 作业运行,我会得到
sed: -e expression #1, char 7: unterminated `s' command
使用任一方法
为什么 sed 在 cron 中的运行方式不同?
在 Windows 中,有问题的评论行是:
FTX368 20/09/2012 VV 10798 - 添加“福利维护”按钮。
所以这是一个聪明的单尾引号 - ASCII 146 - 十六进制 92
答:
0赞
Colin Hay
12/9/2019
#1
我添加了
LC_CTYPE=“POSIX”
到我的脚本,现在两个解决方案在以 cron 运行时都可以正常工作!
我不知道语言环境命令,谢谢o11c
评论
locale