I’m currently writing a complicated Linux bash shell script where I need to keep a counter in an external file, and to do so, I need to be able to write to a file and then read from that file.
In short, this is how I write my counter to that file:
# create a variable to represent the filename
# write to the file
echo "0" > $COUNTER_FILE
Later in the code I increment the counter and write it to the file like this: