We wish to keep a sequence number in a file. When someone wants to get the next sequence number we need to lock the file, get the next number and increment it by one. How do you do that?
I know how to get the number and increment it but how do I lock the file and test that it is locked or not locked.
echo $x > filewithseq
Someone must be doing this already. I know that printer job numbers work in a similar way.