As you can see here, inside each function, im going through each file in the "varA" variable which contains a very huge list of files. i'm echoing the varA variable several times.
how can this be done more efficiently?
btw, i only listed 4 functions here. but in the actual script, there are several functions. so i need this to be very efficient
Anything will be more efficient than the echo | grep | sed | awk | kitchen | sink you have now, but the basic shell for loop is intended for exactly this situation:
for X in $VAR
do
echo "$X"
done
Do not quote $VAR, it depends on it being split on spaces or newlines.
It'd be helpful to see how you're actually using col0(), col1(), etc too.
Take a step back to where that variable is assigned. Where do the values come from? A file? The output of a "command substitution" (that could be redirected to a file as well)?
Why don't you read the values from that file in your functions?
I agree, the taken division into functions seems not optimal.
How often is each function called? A function makes most sense when it is called multiple times.
--
A technical simplification: the two commands
grep "_1_myapp" | sed "s~_1_myapp~~g"
can be done by only sed
sed -n "s~_1_myapp~~gp"
The p modifier prints if a substitution took place.
The -n option suppresses the default print.
The g modifier only makes sense when you expect multiple _1_myapp per line.