Shell how to snapshot a variable?

view story

http://stackoverflow.com – This is my code: # Generate Datetime FILENAME="date +%Y%m%d%H%M%S" # Dump Database dumpdb FILENAME # Upload to S3 python uploaddb.py FILENAME My worry is that I want to keep referring to "FILENAME" variable except every second the variable will change its value. How can I set the value of FILENAME to the current datetime and then keep it at that same value for the reminder of the script, so that FILENAME always refers to the same value. (HowTos)