I've just started scripting and have written a small prog that playes blackjack with the user. What I was wondering, how would I make it so the game saved the amount of money the user won and then loaded this amount the next time the game is played?
Printable View
I've just started scripting and have written a small prog that playes blackjack with the user. What I was wondering, how would I make it so the game saved the amount of money the user won and then loaded this amount the next time the game is played?
Um.. I know how to save in C and C++, but I don't know how to do it in Unix scripting which is what the program is written with.
Here's one way
Code:SCORE=10
echo "SCORE is $SCORE"
echo $SCORE>score.txt
SCORE=0
echo "SCORE is $SCORE"
if [ -f score.txt ]
then
SCORE=$(cat score.txt)
fi
echo "SCORE is $SCORE"
Thanks! Worked perfectly!