I have a question about validating user input regarding number of arguments passed by the user in a bash script. For example, if I use:
if [[ $# -eq 2 ]]
then...
that will check if 2 arguments passed from the command line like this:
./somescript.sh arg1 arg2
but how to validate if user passed 2 arguments when asked? For example:
echo "Type 2 names:"
read...
if [[ user passed more || less than 2 arguments]]
echo "incorrect number of names"
Now if I try to use $# -eq 2 it doesn't work.
What's the proper way to do it?