title: bash—Better way to store variable between runs?
body: <p>I've made a bash script which I run every hour with crontab, and I need to store one variable so that I can access it the next time I run it. The script changes the variable every time it runs, so I can't hardcode it in. Right now I am writing it to a txt file and then reading it back. Is there a better way to do it than this? And the way I am reading the txt file is something I found on here, I don't understand it, and it's kinda clunky. Is there not a built in command for this? Anyway, here's the applicable code, with some of the variables changed to make it easier to read. </p>
  
  <pre><code>while read x; do
    var=$x
  done &lt; var.txt
  
  # Do some stuff, change var to a new value
  
  echo $var &gt; var.txt
  </code></pre>
  
  <p>The variable is only a single integer, so the text file feels overkill.</p>