I have an indexed array called wlist[] which contains bunch of words and i want to parse them into multiple arrays such that every new array will consist of words which have same lenght. I keep getting syntax errors from wcholder$i+=("${wlist[$counter]}")
i tried also to change wcholder$i+=("${wlist[$counter]}") with var=wlist[$counter] eval wcholder$i+=("${!var}")
Code:
#!/bin/bash
.
.
.
# mlength=length of the longest word in wlist[]
# wlength=contains length of every word in the same order in wlist[]
for ((i=1; i<=mlength; ++i))
do
declare -a wcholder$i
done
counter=1
for i in "${wlength[@]}"; do
eval wcholder$i+=("${wlist[$counter]}")
((counter+=1))
done
awkanagrams (there must be some out there). Also a good Awk tutorial , but there are new concepts to grasp there. Good luck.