-
-
Save ZoomQuiet/53439dd21c60a935e793 to your computer and use it in GitHub Desktop.
i hate Chinese symbol! so usage: zhmark2en.sh pwd FILEexNAME
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
VER="zhmark2en.sh {v12.6.27}" | |
echo "$#" | |
if [ "$#" -ne 3 ]; then | |
echo "usage: zhmark2en.sh pwd FILEexNAME" | |
exit 0 | |
fi | |
SED="$(which sed)" | |
PATH=$2 | |
FEX=$3 | |
echo $PATH $FEX | |
echo "walk @\t" $PATH | |
cd $PATH | |
#$SED -ig "s/。/. /g" `/usr/bin/grep 。 -rl ./` | |
$SED -ig "s/。/. /g; \ | |
s/,/,/g; \ | |
s/、/,/g; \ | |
s/?/\?/g; \ | |
s/!/\!/g; \ | |
s/;/;/g; \ | |
s/“/\"/g; \ | |
s/”/\"/g; \ | |
s/‘/\'/g; \ | |
s/’/\'/g; \ | |
s/﹃/\"/g; \ | |
s/﹄/\"/g; \ | |
s/﹁/\'/g; \ | |
s/﹂/\'/g; \ | |
s/(/(/g; \ | |
s/)/)/g; \ | |
s/《/<</g; \ | |
s/》/>>/g; \ | |
s/【/\[/g; \ | |
s/】/\]/g; \ | |
s/『/\[/g; \ | |
s/』/\]/g; \ | |
s/……/... /g; \ | |
s/:/:/g; \ | |
s/——/--/g" \ | |
$PATH/*.$FEX | |
#echo "###::end@ " `date +"%Y/%m/%d %H:%M:%S"` | |
echo "$VER transformed all Chinese Mark into en. ;-)" | |
exit 0 |
其实弯角引号/撇号、HORIZONTAL ELLIPSIS(半个中文省略号)和 EM DASH(半个中文破折号)在英文里也使用的呀…
#!/bin/sh
# Change log
# v15.10.10 upgrade fro EI Captain
# as http://blog.csdn.net/wqhjfree/article/details/39032533
# http://stackoverflow.com/questions/11287564/getting-sed-error-illegal-byte-sequence-in-bash
# v15.4.10 upgrade fro Yosemite
# v12.6.27 can usage
export LC_COLLATE='C'
export LC_CTYPE='C'
VER="zhmark2en.sh {v15.10.10}"
SED="$(which sed)"
echo "\t powered from $VER"
echo "Number of arguments: $#"
if [ "$#" -lt 1 ]; then
echo "usage: zhmark2en FILEexNAME(txt/md/...)"
exit 0
fi
if [ "$#" -gt 2 ]; then
echo "usage: zhmark2en FILEexNAME(txt/md/...)"
exit 0
fi
# -eq 等于
# -ne 不等于
# -le 小于等于
# -ge 大于等于
# -lt 小于
# -gt 大于
#echo "?" $0
#echo "??" $1
#echo "???" $2
#echo "????" $3
PATH=$(pwd) #$2
FEX=$1 #$3
echo $PATH $FEX
echo "walk @\t" $PATH
echo "will clean Chinese Mark in :"
echo *.$FEX
#cd $PATH
#$SED -ig "s/。/. /g" `/usr/bin/grep 。 -rl ./`
#$SED -i "s/。/. /g; \
#$SED -i.orig "s/。/. /g; \
$SED -i "" "s/。/. /g; \
s/,/,/g; \
s/、/,/g; \
s/?/\?/g; \
s/!/\!/g; \
s/;/;/g; \
s/:/:/g; \
s/……/... /g; \
s/…/... /g; \
s/“/\"/g; \
s/”/\"/g; \
s/‘/\'/g; \
s/’/\'/g; \
s/(/(/g; \
s/)/)/g; \
s/{/{/g; \
s/}/}/g; \
s/《/\"/g; \
s/》/\"/g; \
s/〈/\'/g; \
s/〉/\'/g; \
s/〔/\[/g; \
s/〕/\]/g; \
s/[/\[/g; \
s/]/\]/g; \
s/【/\[/g; \
s/】/\]/g; \
s/〖/\[/g; \
s/〗/\]/g; \
s/『/\"/g; \
s/』/\"/g; \
s/「/\'/g; \
s/」/\'/g; \
s/﹃/\"/g; \
s/﹄/\"/g; \
s/﹁/\'/g; \
s/﹂/\'/g; \
s/——/---/g" \
$PATH/*.$FEX
#echo "###::end@ " `date +"%Y/%m/%d %H:%M:%S"`
echo "\t $VER transformed all Chinese Mark into en. ;-)"
exit 0
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
问题是俺每次
这样运行后,都产生一大堆
*.mdg
文件,内容是原始文件参考:
mac os 中用 sed 命令 替换文本中的指定内容
为毛?!
probelm is running:
will gen. *.mdg files, content originality files
so i just want replace somethin just in originality files.
not need backup.
感谢 SHLUG 高手的热心解答:
其实就是不认真问
man
的原因!关键就是那个
zero-length
在bsd样的 sed 中要表述为俺又一次 #图样图森破 了...