【问题标题】:Script which replaces special ASCII keys with text用文本替换特殊 ASCII 键的脚本
【发布时间】:2014-11-21 20:27:13
【问题描述】:

我正在编写一个将特殊字符转换为文本的脚本。

如何安排它,以便我的脚本将 csv 文件作为输入并在其上执行 sed 命令?

FILENAME= ls -ltr| grep *.csv

sed -i 's/\xc3\x83/A/g' FILENAME #Ã <br>
sed -i 's/\xc3\x80/A/g' FILENAME #À<br>
sed -i 's/\xc3\x81/A/g' FILENAME #Á<br>
sed -i 's/\xc3\x82/A/g' FILENAME #Â<br>
sed -i 's/\xc3\x85/A/g' FILENAME #Å<br>

【问题讨论】:

标签: bash unix command-line sed


【解决方案1】:

您可以将 sed 命令简化为

sed -i 's/\xc3\x8[0-5]/A/g' FILENAME

遍历目录中的所有 csv 文件并应用 sed

for FILENAME in *.csv
do
 sed -i 's/\xc3\x8[0-5]/A/g' $FILENAME
done

【讨论】:

    猜你喜欢
    • 2021-03-06
    • 2013-12-23
    • 2013-11-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多