Answer the question
In order to leave comments, you need to log in
How to implement argument checking in bash?
Hello. How to check passed arguments in a bash script? For example, now I am executing the script like this: ./script.sh arg arg2 arg3 But this is not very good, because you can miss, and data from $2 to $1 will go into work, for example. How would you implement validation of input arguments, for example ./script.sh ip=1.1.1.1 host=domain.ltd etc... ?
Answer the question
In order to leave comments, you need to log in
You need shflags - https://code.google.com/p/shflags/
Usage example - https://debian.pro/files/anlamp/mksite.sh (look in the script header)
Ready package for debian/ubunt - https ://debian.pro/files/anlamp/libshflags_1.0.3-y...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question