Your main question is explained here:
http://mywiki.wooledge.org/BashFAQ/024
But more than that, I can't quite understand what the command is supposed to do. The whole logic seems off to me.
Are you just trying to add a number prefix to each of the found instances? If that's the case it would probably be better to simply save the results to an array and use a separate loop to do the print work.
Code:
lqarray=( $(wget -q "http://www.linuxquestions.org/" -O - | grep ".lqconsulting." | cut -d/ -f3 | cut -d. -f2 ) )
i=1
for text in "${lqarray[@]}"; do
echo "$i. $text"
(( i++ ))
done
There are probably also cleaner ways to extract the text you want than chaining multiple
grep and
cut commands, if I knew exactly what text you were trying to match.
Could you please explain what your
real goal is, so we can help you to come up with a cleaner solution?