1. manish

    is there a variable in getopts which stores the error message.
    while getopts "a:" opt
    case $opt in
    a) echo "found a";;
    *) echo "invaid parameter"
    echo "code successfully executed"

    I want that when i run this code without passing parameter to -a, the code should stop executing and the last line should not be printed out.
    Is there a way?

  2. thanks

    i recently discovered bash had getopts -- I always used the tried and true method of SHIFT ;
    I will have to borrow you sample for my next bash tool.


  3. Hi,
    Thanks very much for this blog.
    Really helpful.

  4. Ben Patridge

    Thank you for this. It was extremely helpful!

  5. Dan Saint-Andre

    Another aspect of command-line option processing involves what I call "qualifiers." When building an application, some options might be required. Other options might be completely, well, optional. Still other options might require one or more different options to clarify or modify the behavior of the primary option. Some options might be mutually exclusive. I think that you get the idea.
    While we can implement rules and program logic to enforce these "qualifiers," it might be nice to have something in a table or similar so that our application need not have pages of ad hoc code to do the work.

    ~~~ 0;-Dan


Leave a Reply

Your email address will not be published. Required fields are marked *