[英]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 - Hex 92
我加了
LC_CTYPE="POSIX"
到我的腳本,現在無論是否以 cron 運行,這兩種解決方案都可以正常工作!
我不知道 locale 命令,感謝 o11c
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.