[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: 问一个sed的问题



sed -i[.backup-postfix] -e '...' files

这个-i选项是在sed版本4以后加入的
,所以如果你用的是之前的版本话,就无法用到这个功能了,此时可以用perl完成相同的功能,

perl -pi[.backup-postfix] -e '...' files


On 11/30/06, lnxpgn <lnxpgn@gmail.com> wrote:
如果你的sed有-i选项
sed -i -e 's/xxxxx/sssss/' *.html
如果没有可以用一个简单的脚本
-----------------------------
#!/bin/sh

for file in `ls *.cpp`;do
sed -e 's/xxxxx/ssss/' $file >tmpfile
cp tmpfile $file
done
rm -f tmpfile
-----------------------------

去掉/*xxxxxxxxx*/样式的注释

sed -r -e 's/\/\*.*\*\///g' test.cpp

jun yu 写道:
> sed默认是输出到stdout里,但是当我需要对多个文件进行替换操作时,就有问
> 题了,比如:
>
> sed -e 's/xxxxx/sssss/' *.html
>
> html文件有很多个,不知道怎么样才能替换多个文件。
>
> 感觉应该是通过多个命令行工具组合来进行,但是就是一下子想不明白。
>
> 谁有这方面的经验吗?


--
To UNSUBSCRIBE, email to debian-chinese-gb-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org



Reply to: