Computer scienceSystem administration and DevOpsCommand lineBash syntax

Case statement and argument parsing

Args

Report a typo

You are given the following bash script named choose.sh.

#!/usr/bin/env bash

function add() {
    echo $(( $1 + $2 ))
}

function subtract() {
    echo $(( $1 - $2 ))
}

case $1 in
    add )
        add $2 $3;;
    subtract )
        subtract $2 $3;;
    * )
        echo "unknown operation";;
esac

Write a command to execute this script from the command line to subtract 5 from 3.

Write the command based on the following format; bash choose.sh .... Include necessary arguments in this command to give the expected result.

Enter a short text
___

Create a free account to access the full topic