0

I need to create a function and pass an argument like

myfunc word_100

and then the output should display

word_101

Basically it should increment taking in account the delimiter. I am thinking to say put word as one variable and the number and increment the number and combine it together. But not sure how to go about.

jww
  • 90,984
  • 81
  • 374
  • 818
Ria
  • 23
  • 3

1 Answers1

1

Try:

NAME=${1%_*}_
NUM=${1##*_}
echo $NAME`expr $NUM + 1`
Nick
  • 4,077
  • 18
  • 33
  • 45