increment a variable inside a for loop to rename all text files that start with a certain string.
#!/bin/bash for files in old*.txt do ((i++)) mv $files $(echo $files | sed -E 's/[0-9]+\.txt//')OLDOLD$i.txt done