I need to open a file using c shell. The file contains a single integer, and I need to put it into a variable, increase it and put back into the file. Meaning, if the file contains the number 5, I need, after the program runs, that the file contains the number 6. Any suggestions?
+1
A:
You can use the @
command to evaluate it as numeric expression.
% echo 100 > test.txt
% set f = `cat test.txt`
% echo $f
100
% @ f = $f + 1
% echo $f
101
% echo $f > test.txt
% cat test.txt
101
Pasi Savolainen
2010-04-16 13:58:32
worked perfectly. Thank you :)
n00b programmer
2010-04-17 15:34:21