Bash: saving settings to file

This is a wiki page. Be bold and improve it!

If you have any questions about the content on this page, don't hesitate to open a new ticket and we'll do our best to assist you.


# Create variable
# Save variable to file:
echo 'VERSION="'"$VERSION"'"' >> .variables

# Source file to load variables:
. .variable
echo "$VERSION"
# Increment:
echo "$VERSION"
# Delete previous value from file:
sed --in-place  '/^VERSION=/d' ./.variables
# Save new value:
echo 'VERSION="'"$VERSION"'"' >> .variables
# Note that the above, simple implementation will append a new line to .variables each time the value is saved. $VERSION will still evaluate to the last value saved, though.