I have a couple of arguments inside a list (array, e.g.
$@) and I'd like to know if the option
-v is in the list.
In Python I would simply do:
verbose = "-v" in sys.argv
How do I achieve that in shell without much code?
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It only takes a minute to sign up.Sign up to join this community
Note that your Python code is not correct except in extremely simple cases. It detects an argument
-v anywhere on the line, even if it's the argument of another option or after non-option arguments. The correct way to parse options in Python is with