I have limited experience with Shell scripting. I was trying to print the comma-separated field with their index number.
I found a similar question here Variables in bash seq replacement ({1..10}) .
IN="abc,def,123"
for i in $(echo "$IN" | tr "," "\n")
do
echo $i
done
How can we also print the counter number?
My attempt:
count=1
for i in $(echo "$IN" | tr "," "\n")
do
echo $count $i
count+=1
done
But this does not work.