I know that there are a lot of solutions on how to increment a variable inside a loop, but I'd like to know how to increment a variable which is a already a result from a command.
Suppose I have files: test1 test2 test3 test4.
My command is the following:
for i in {1..4}; do x$i=$(wc -l < test$i); done
I get:
x1=10: command not found
x2=9: command not found
x3=9: command not found
x4=9: command not found
which command could not be found? wc -l?
I guess the problem is related with the position of $symbol
x1=10, for example. This doesn't solve your problem, so this is just a comment for your future reference in command line or script debugging.