Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6606591
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T19:24:44+00:00 2026-05-25T19:24:44+00:00

Example: ./myscript –ip 192.168.1.1 –port 1985 or another possible ./myscript –port 1985 –ip 192.168.1.1

  • 0

Example:

./myscript --ip 192.168.1.1 --port 1985

or another possible

./myscript --port 1985 --ip 192.168.1.1

I want to allow my script to take a set of arguments, in any order

./myscript a b c d
./myscript d c b a
./myscript b d a c

Etcetera

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T19:24:44+00:00Added an answer on May 25, 2026 at 7:24 pm

    take a look at getopts

    getopts: getopts optstring name [arg]
    Parse option arguments.

    Getopts is used by shell procedures to parse positional parameters
    as options.

    OPTSTRING contains the option letters to be recognized; if a letter
    is followed by a colon, the option is expected to have an argument,
    which should be separated from it by white space.

    Each time it is invoked, getopts will place the next option in the
    shell variable $name, initializing name if it does not exist, and
    the index of the next argument to be processed into the shell
    variable OPTIND. OPTIND is initialized to 1 each time the shell or
    a shell script is invoked. When an option requires an argument,
    getopts places that argument into the shell variable OPTARG.

    getopts reports errors in one of two ways. If the first character
    of OPTSTRING is a colon, getopts uses silent error reporting. In
    this mode, no error messages are printed. If an invalid option is
    seen, getopts places the option character found into OPTARG. If a
    required argument is not found, getopts places a ‘:‘ into NAME and
    sets OPTARG to the option character found. If getopts is not in
    silent mode, and an invalid option is seen, getopts places ‘?’ into
    NAME and unsets OPTARG. If a required argument is not found, a ‘?‘
    is placed in NAME, OPTARG is unset, and a diagnostic message is
    printed.

    If the shell variable OPTERR has the value 0, getopts disables the
    printing of error messages, even if the first character of
    OPTSTRING is not a colon. OPTERR has the value 1 by default.

    Getopts normally parses the positional parameters ($0 – $9), but if
    more arguments are given, they are parsed instead.

    Exit Status:
    Returns success if an option is found; fails if the end of options is
    encountered or an error occurs.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a perl script and I want to do the following: system(source myscript.sh);
Normally you can execute a Python script for example: python myscript.py , but if
I have a php script http://example.com/myapp/myscript.php running on an Apache server. I call this
Say I have a file at the URL http://mywebsite.example/myscript.txt that contains a script: #!/bin/bash
example: I want to see if array[5] holds a value or is empty.
Example C API signature: void Func(unsigned char* bytes); In C, when I want to
Example: find / * Gives me all files and directories, but I want only
For example this line fails: $ nohup for i in mydir/*.fasta; do ./myscript.sh $i;
If I have a script tag like this: <script id = myscript src =
I have a script that generate me some command that I must execute... Example:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.