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

  • SEARCH
  • Home
  • 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 7011839
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T22:10:41+00:00 2026-05-27T22:10:41+00:00

I am writing my first ever Shell script today. I think I have found

  • 0

I am writing my first ever Shell script today. I think I have found everything I need online but need help on one thing:

I want to be able to pass a couple of optional arguments when the script is called: e.g myscript.sh -filename somefilename -location some/file/location -deleteoption yes

all them 3 options are optional so I need my script at the very first stage to loop through each argument and then depending on the descriptor of the argument (e.g -filename) store the value (somefilename) in to the correct variable?

another thing is that the options can be given in any order.

How do I go about achieving this functionality?

  • 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-27T22:10:42+00:00Added an answer on May 27, 2026 at 10:10 pm

    If you’re using bash, you might want to use getopts. Otherwise, googling for “shellname option parsing” should return something similar for your shell of choice.

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

Sidebar

Related Questions

I am writing my first shell-script ever and I am trying to connect to
I am writing my first ever code for AWS. I have downloaded the AWS
I am writing my first ever bash script, so excuse the noobie-ness. It's called
This is my first Perl script. Ever: #!/usr/bin/perl if ($#ARGV < 1) { die(usage:
This is my first ever attempt at writing a recursive function in c. The
Morning All, I have been writing an ever so simple IRC client in visual
This is my first post ever :). I have quite a bit of experience
I'm writing my first ever C# application, for Windows Phone Mango. It's designed to
I am writing my first ever plugin for rails. The plugin is supposed to
the iphone app I am writing shows white screen when first launched, but become

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.