I need to sum the number of lines from different text files like: x_red, x_green which have some information inside of them, and this is what I got:
counter=0
colors=`cat manyColors.txt`
addPrefix(){
echo "x_$1"
}
for color in colors
do
# cat `addPrefix $color` | wc -l # will give me the nº of lines just fine
counter=$(($counter + cat `addPrefix $color` | wc -l ))
done
So yeah, the counter isn't really incrementing properly and I have no ideia how to sum those arguments properly, what am I missing here?
Edit: Also, how can I turn
" cat addPrefix $color
|wc -l ", into a variable?
Edit2: Added the function and changed the function name, for misunderstandings.. Sorry I know it's still kinda confusing