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 6230687
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T09:47:40+00:00 2026-05-24T09:47:40+00:00

FILE_LIST=$1 MOVE=0 while getopts m OPT; do case $OPT in m) MOVE=1 ;; M)

  • 0
FILE_LIST=$1
MOVE=0
while getopts "m" OPT; do
 case $OPT in
          m) MOVE=1 ;;
          M) MOVE=1 ;;
          *) echo "Invalid parameter." >&2; exit 1 ;;
 esac
done

echo $MOVE

echo $FILE_LIST

I will pass optional argument ( -m/-M) and file list .

test.sh -m a.txt 

its display 1 -m , but i am looking for 1 a.txt

Supost if test.sh a.xt 

it should be diplsay 0 and a.txt

  • 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-24T09:47:43+00:00Added an answer on May 24, 2026 at 9:47 am

    You need to shift the arguments.

    MOVE=0
    while getopts "mM" OPT; do
     case $OPT in
              M|m) MOVE=1
                   shift;;
              *) echo "Invalid parameter." >&2; exit 1 ;;
     esac
    done
    
    echo $MOVE
    FILE_LIST=$1
    echo $FILE_LIST
    

    You can also combine m and M into one case.

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

Sidebar

Related Questions

Is there an MSBuild task that will move a file OR a folder? Core,
While moving some code around for investigation purposes, I came across a little feature
I have an app that cleans dirty filenames. Dirty filenames have #%&~+{} in their
I have a program with two modes: GUI & Just Run. GUI loads a
With TortoiseSVN, I can move a file into the ignore-on-commit changelist, so that when
I'm trying to make a loop that will recurse through an array of bytes
The question is a bit complicated so I will try and explain. I have
A script I wrote was meant to move individual day directories from an old
I have a task where I need to move a bunch of files from
//file list.h #include stdafx.h namespace st { struct My_List; typedef My_List list; list* create(const

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.