Here's a crude way (no error checking) to do it purely in bash:
#helper function to convert a number to the corresponding character chr() { [ "$1" -lt 256 ] || return 1 printf "\\$(printf '%03o' "$1")" } #helper function to convert a character to the corresponding integer ord() { LC_CTYPE=C printf '%d' "'$1" } #increment file fn_incr(){ #first split the argument into its constituent parts local fn prefix letter_and_suffix letter suffix next_letter fn=$1 prefix=${fn%_*} letter_and_suffix=${fn#${prefix}_} letter=${letter_and_suffix%%.*} suffix=${letter_and_suffix#*.} #increment the letter part next_letter=$(chr $(($(ord "$letter") + 1))) #reassemble echo "${prefix}_${next_letter}.${suffix}" } Example usage:
fn_incr foo_bar_A.min.js #=> foo_bar_B.min.js Doing it in-bash with multiple-letter indices would require longer code. You could always do it in a different executable, but then you might want to increment the filenames in batches or else the executable startup overhead might slow down your program unacceptably. It all depends on your use case.
Using plain old integers might be the better choice here as you won't have to manually manage how 9++ overflows to the left.
chr() and ord() have been shamelessly stolen from Bash script to get ASCII values for alphabetBash script to get ASCII values for alphabet