tags:

views:

20

answers:

2

Hey, I have a short text file with the following syntax:

FileName: some 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

+1  A: 

Why not just use sed?

sed -i 's/^Version: .*$/Version: 99/' foo.txt
Lukáš Lalinský
Well, that worked.. Thanks!I don't know what I did wrong, but it works now :)
Udi
A: 

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.

Kinopiko