Skip to main content
edited tags
Link
Kusalananda
  • 356.3k
  • 42
  • 737
  • 1.1k
added 125 characters in body
Source Link

I have two scripts that work together by themselves and I have no idea how to make them work together

the task is to make a bash script accept operators and a list of integers and having the command perform the operations.

I basically need to be able to use the script as such

test.sh add 1 2 3
5
test.sh sub 4 2 1
1

the first script I have is

for var in $@
do

sum=$(( sum + var ))
done
echo $sum

second script is

if [ $operator = add ]; then
add= echo $(($a+$b))

elif 

I'm not really sure how to combine them to make it so I can get

test.sh add 1 2 3
5

I have two scripts that work together by themselves and I have no idea how to make them work together

I basically need to be able to use the script as such

test.sh add 1 2 3

the first script I have is

for var in $@
do

sum=$(( sum + var ))
done
echo $sum

second script is

if [ $operator = add ]; then
add= echo $(($a+$b))

elif 

I'm not really sure how to combine them to make it so I can get

test.sh add 1 2 3
5

I have two scripts that work together by themselves and I have no idea how to make them work together

the task is to make a bash script accept operators and a list of integers and having the command perform the operations.

I basically need to be able to use the script as such

test.sh add 1 2 3
5
test.sh sub 4 2 1
1

the first script I have is

for var in $@
do

sum=$(( sum + var ))
done
echo $sum

second script is

if [ $operator = add ]; then
add= echo $(($a+$b))

elif 
added 4 characters in body
Source Link

I have two scripts that work together by themselves and I have no idea how to make them work together

I basically need to be able to use the script as such

test.sh add 1 2 3

the first script I have is

for var in $@
do

sum=$(( sum + var ))
done
echo $sum

second script is

if [ $operator = add ]; then
add= echo $(($a+$b))

elif 

I'm not really sure how to combine them to make it so I can get

test.sh add 1 2 3
5

I have two scripts that work together by themselves and I have no idea how to make them work together

I basically need to be able to use the script as such

test.sh add 1 2 3

the first script I have is

for var in $@
do

sum=$(( sum + var ))
done
echo $sum

second script is

if [ $operator = add ]; then
add= echo $(($a+$b))

elif 

I'm not really sure how to combine them to make it so I can get

test.sh 1 2 3
5

I have two scripts that work together by themselves and I have no idea how to make them work together

I basically need to be able to use the script as such

test.sh add 1 2 3

the first script I have is

for var in $@
do

sum=$(( sum + var ))
done
echo $sum

second script is

if [ $operator = add ]; then
add= echo $(($a+$b))

elif 

I'm not really sure how to combine them to make it so I can get

test.sh add 1 2 3
5

Source Link
Loading