Hi all, who reacted on my question how to add a number to a env var.
I hadn't expected so much reactions to my question : thanks
Perhaps you are curious about which option I choose
Now I have to disappoint you all : none
The reason I asked this question was that I was writing a small
script in which some system files were overwritten by new ones.
As I didn't want to destroy the original files,I wanted the script
to make a backup of those original files. Most simple at that point
seemed to mv <original file> <original file>.org, however you can
only do this once. So I thought : wouldn't it be nice to have a number
i.s.o. org, which is increased each time I update the files.
In the original post I said I wanted to increase an environment
variable, but this wasn't quite true, a shell variable will do the
Then, when I'd just finished the script, I happened to look at the
man page for mv and guess what I read there ?
The linux version of mv (and cp) supports exactly what I wanted :
an extension which is incremented each time you overwrite the
If I'd formulated my question better, all you would of course
have mentioned this option to me. On the other hand, now I know
how to do simple calculations in a shell script. Besides that
the Sun I use at my work, doesn't have such nice mv and cp commands.