1

I want to replace the 2 in "2p" with the i variable value each time on the for loop.

count1=0
for i in 2 3 4 5 6 7 8 9 10 11
do
var=`cat participantes | cut -d '-' -f4 | sed -n 2p`
echo $var
count1=`expr $count1 + $var`
done

echo $count1
Leo1989
  • 23
  • 3
  • 1
    try this. `... sed -n ${i}p` – balki Aug 28 '22 at 22:47
  • 1
    Does this answer your question? [Replace a string in shell script using a variable](https://stackoverflow.com/questions/3306007/replace-a-string-in-shell-script-using-a-variable) – Nic3500 Aug 29 '22 at 00:08

0 Answers0