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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T11:09:09+00:00 2026-06-11T11:09:09+00:00

Some may have found out that in Ubuntu when you install or update via

  • 0

Some may have found out that in Ubuntu when you install or update via terminal

you get a question similar to

“do you with to install or remove package [Y/n]?”

when you press enter its like its the same as when you type “Y” or “y”

So i was wondering how to make that in bash
This is what i have so far?

echo "question?[Y/n]"
read choose
if [ $choose ~= "Y" ] [ $choose ~= "y" ] [ $choose ~= "" ]
then 
#code
fi
  • 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-06-11T11:09:10+00:00Added an answer on June 11, 2026 at 11:09 am

    Classically (meaning it will work in POSIX-ish shells other than bash), you’d write:

    echo "Question? [Y/n]"
    read choose
    if [ "$choose" = "Y" ] || [ "$choose" = "y" ] || [ -z "$choose" ]
    then 
        # code
    fi
    

    The quotes ensure that the test operator see an argument even if $choose is an empty string.

    The [[ operator seems to allow you to get away without quoting strings, but is not part of a POSIX shell. POSIX recognizes its existence by noting:

    The following words may be recognized as reserved words on some implementations (when none of the characters are quoted), causing unspecified results:

    [[    ]]    function    select
    

    If you want the shell to leave the cursor on the same line as the prompt, you can use:

    printf "Question? [Y/n] "
    

    POSIX shells recognize the \c escape; bash does not:

    echo "Question? [Y/n] \c"
    

    (There may be a way to make bash handle that, but printf is probably more portable.)

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

Sidebar

Related Questions

Have done some research and found some stuff that may be helpful. I would
We have some stuff that may be exported into various formats. Currently we have
I have model Article it has field title with some text that may contain
Common situation: I have a client on my server who may update some of
I have a question that may have been answered over 9000 times before but
I'm just starting out with Python, and have found out that I can import
I'm using a Java wrapper for SQLite called SQLiteJDBC - this may have some
In my java application, I have some entity, some of them may have the
I think we may have trouble with our existing project. For some reasons we
I have a favorite table containing some fields like login_id,driver_id(One login_id may have many

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.