I'm trying to write a script that backs up a file which is given as parameter, in a way that a running number should be added to each copy of the file. For example, if the name of the original file was aa.c, then the first backup copy will be called aa.1.c. In the next time backup is run, the copy should be called aa.2.c, then aa.3.c, and so on. In addition ,the script should automatically find the copy with the highest number, and use it to create the new number.
Anyone know how can I do that with foreach loop?