Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Append Integer To String Bash Script OSX

I am attempting to write a bash script that loops exactly 20 times and then appends each number in the loop to the variable with a string "group". The output of each variable should be group1, group2, group3, and so on. Unfortunately i am unable to get this to work. Here is my code thus far:

   #!/bin/bash

   USERNUM=0
   USERPREFIX='group'

   for (( i = 1 ; i <= 20; i++ ))

   do

   USERNUM=$(($USERNUM+1))

   USERCREATE=$(($USERPREFIX+$USERNUM))

   echo $USERCREATE

   done

I am trying to run this script under OSX 10.6. Any help is greatly appreciated.

like image 507
user1227118 Avatar asked Dec 31 '25 22:12

user1227118


1 Answers

USERCREATE="$USERPREFIX$USERNUM"
like image 51
Ignacio Vazquez-Abrams Avatar answered Jan 02 '26 13:01

Ignacio Vazquez-Abrams