Ok so I was wondering if it is possible to save like a variable in bash. I am writing a script where you build like farms and mines and I was just wondering if it is possible to bring back those variables even after I stopped the program and then got back on. So lets say I have built 4 farms farms would be farm=4, can I bring this variable back somehow? I know how to make a page that you can make a high scores list on (Which I did for a guessing game.), but this I don’t know if it is possible in bash.
Share
You can save all needed variables in a file (using here-doc):
and to recreate your previous environment :
or
EXPLANATIONS
sourcecommand is the top of your script after the shebangHelp said :
NOTE
if you want for some reasons to dynamically generate the files with pattern matching on variable names :
printf '%q\n' $(set | grep "suffix=") > save_fileprintf '%q\n' $(set | grep "^prefix") > save_fileThanks gniourf_gniourf for
printftrick.