It\'s not possible to invoke the same rake task from within a loop more than once. But, I want to be able to call rake first and loop through an array
invoke
rake first
This worked for me, it's quite easy to understand you just need to loop you bash command.
task :taskname, [:loop] do |t, args| $i = 0 $num = args.loop.to_i while $i < $num do sh 'your bash command'' $i +=1 end end