Skip to main content
deleted 22 characters in body; edited tags
Source Link
Gilles 'SO- stop being evil'
  • 865.4k
  • 205
  • 1.8k
  • 2.3k

I would like to run a for loop for a set of variables which I incorrectly denote as {A,B}. Following that my script looks like:

#!/bin/sh
 
for {A,B} in {1,2}  {3,4} {5,6} {7,8}
do
 
echo A=$A B=$B
 
C=$(($A+$B))
 
echo Sum,C = $C
 
done

How can I correct it?

I would like to run a for loop for a set of variables which I incorrectly denote as {A,B}. Following that my script looks like:

#!/bin/sh
 
for {A,B} in {1,2}  {3,4} {5,6} {7,8}
do
 
echo A=$A B=$B
 
C=$(($A+$B))
 
echo Sum,C = $C
 
done

How can I correct it?

I would like to run a for loop for a set of variables which I incorrectly denote as {A,B}. Following that my script looks like:

#!/bin/sh
for {A,B} in {1,2}  {3,4} {5,6} {7,8}
do
echo A=$A B=$B
C=$(($A+$B))
echo Sum,C = $C
done

How can I correct it?

edited title
Link
hbaromega
  • 171
  • 2
  • 8

For loop for a set of variables

improved
Source Link
hbaromega
  • 171
  • 2
  • 8

I would like to run a for loop for a set of variables which I incorrectly denote as {A,B}. Following that my script looks like:

#!/bin/sh

for {A,B} in {1,2} , {3,4}, {5,6}, {7,8}
do

echo A=$A B=$B

C=$(($A+$B))

echo Sum,C = $C

done

How can I correct it?

I would like to run a for loop for a set of variables which I incorrectly denote as {A,B}. Following that my script looks like:

#!/bin/sh

for {A,B} in {1,2} , {3,4}, {5,6}, {7,8}
do

echo A=$A B=$B

done

How can I correct it?

I would like to run a for loop for a set of variables which I incorrectly denote as {A,B}. Following that my script looks like:

#!/bin/sh

for {A,B} in {1,2}  {3,4} {5,6} {7,8}
do

echo A=$A B=$B

C=$(($A+$B))

echo Sum,C = $C

done

How can I correct it?

Source Link
hbaromega
  • 171
  • 2
  • 8
Loading