Please help as i want to validate arguments passed while executing the script .
What i want that user can only give values as parameter those are valid as per script.
./script.sh abc xyz where abc is a folder location which can be any location and xyz is either yes or no. if user enter any other word apart from yes or no then my message should be displayed and exit there only.
sample given below:
if [ $# -eq 2 ]; then
if (($test1 == "audit") || ($test1 == "insert")); then
echo "" or continue with the main script
else
echo "please pass arguments like sample - Sample: ./script.sh b1 audit. "
exit 0;
fi
else
echo "invalid argument please pass only 2 argument "
echo "Sample: ./script.sh b1 audit"
exit 0;
fi
Our community of experts have been thoroughly vetted for their expertise and industry experience.
The Most Valuable Expert award recognizes technology experts who passionately share their knowledge with the community, demonstrate the core values of this platform, and go the extra mile in all aspects of their contributions. This award is based off of nominations by EE users and experts. Multiple MVEs may be awarded each year.
The Distinguished Expert awards are presented to the top veteran and rookie experts to earn the most points in the top 50 topics.