开发者

CShell word replacement

I have a short text file with the following syntax:

FileName: some开发者_如何学C name
Version: 3
Length: 45
hello, this is an irrelevant, unimportant text.
So is this line.

Now, I'm trying to write a script that replace the version number with a given new number.

Anyone knows how to? I really don't mind it to be ugly

thanks, Udi


Why not just use sed?

sed -i 's/^Version: .*$/Version: 99/' foo.txt


I don't know how to do it in csh. However, at the risk of coming across as one of those annoying people who tells you to use their favourite thing at every opportunity, there are better ways than using csh. The traditional unix command sed is good at this stuff, or a language like Perl is also useful.

perl -p -i -e 's/Version: 3/Version: 4/g;' myfile

should do it.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜