Increment a variable name within a BASH loop

#!/bin/bash
c=0
for i in a b; do
	log[$c]="$i"
	((c++))
done
for i in ${log[@]}; do
	echo $i
done

Example

# ./btest
a
b
This entry was posted in Command Line FU and tagged , , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *