[Repeating same command n times. Question has been asked before](https://stackoverflow.com/questions/3737740/is-there-a-better-way-to-run-a-command-n-times-in-bash)

But methods in that question are not working for variable assignments

Eg.

```
var='abc,xyz,mnx,duid'
for f in `seq 3`; do var=${var%,*}; done

```

Above works but using it in function as described in other question does't work

Eg.

```
repeat() { num="$"; shift; for f in $(seq $num); do $1; done; }
repeat 3 'var=${var%,*}'
repeat 3 "var=${var%,*}"

```

Doesn't work