If there's zeros or more than 2 inputs, a message will be shown to the user.
I don't have much idea of how to check, how many values have been passed from the command line. Can I get a simple program?
If there's zeros or more than 2 inputs, a message will be shown to the user.
I don't have much idea of how to check, how many values have been passed from the command line. Can I get a simple program?
Below is an example code which will return "no argument passed" if no argument is passed:
#!/bin/bash
if [ $# = 0 ];
then
echo "No argument is passed"
fi
Arguments is handled by bash with multiple option, below for your reference:
$# is the number of parameters passed
$0 returns the name of the shell script running as well as its location in the file system
$* gives a single word containing all the parameters passed to the script
$@ gives an array of words containing all the parameters passed to the script