I have a text file a.txt whose content is a number between 0 and 100. I need a single command which modifies a.txt by increasing by 10 the number, but under the constraint that the final result has to be less than 100 (i.e. if the number reaches a value larger than 100 (e.g. 95+10=105), it just stays on 100).
I need also a command to decrease by at most 10 but in such a way that the final result is greater or equal than 0, it should be analogous.
What I can do, is to modify the file directly with echo, but in this way I can just replace the number with something else (and not adding to the previous number).
bash
; it's far from my standards now but it worked well enough. It's on a computer at home, though, so I'll have to post it later. – Wildcard Dec 16 '15 at 19:36