【发布时间】:2014-01-18 00:37:39
【问题描述】:
我有一个名为test 的文件夹,其中有两个文件style.css 和一个名为.DS_Store 的隐藏文件。我的目标是将test 下所有文件中的所有“changefrom.this”字符串递归替换为“to.this”。所以我想出了:
folder_root="test"
# change text in files
find $folder_root/ -type f -print0 | xargs -0 -n 1 sed -i -e 's/changefrom.this/to.this/g'
例如,虽然字符串确实在 style.css 文件中被替换,但执行会输出错误:
sed: RE error: illegal byte sequence
我在test 文件夹中获得了一些新文件:style.css-e 和!2766!.DS_Store。没想到。这是怎么回事?
【问题讨论】: