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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T03:41:58+00:00 2026-05-31T03:41:58+00:00

$ man bash Word splitting and filename expansion are not performed on the words

  • 0
$ man bash

Word splitting and filename expansion are not performed on the words between the ‘[[’ and ‘]]’; tilde expansion, parameter and variable expansion, arithmetic expansion, command substitution, process substitution, and quote removal are performed.

$ echo $BASH_VERSION
4.2.10(1)-release

command 1

$ [[ "hello" =~ "he"   ]] && echo YES || echo NO
YES

command 2

$ [[ "hello" =~  he.*  ]] && echo YES || echo NO
YES

command 3

$ [[ "hello" =~ "he.*" ]] && echo YES || echo NO
NO

Why command 2 and 3 are different?

  • 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-31T03:41:59+00:00Added an answer on May 31, 2026 at 3:41 am

    Check your bash version. Starting from version 3.2 this behavior was added that states:

    Quoting the string argument to the [[ command’s =~ operator now forces
    string matching, as with the other pattern-matching operators.

    I guess you are using bash >= ver 3.2 for your test.

    That’s the reason when you quote the regular expression it is doing plain simple string matching instead of regex matching.

    Update: If you want regex matching inside double quotes then use:

    shopt -s compat31
    

    As per the manual:

    compat31

    If set, bash changes its behavior to that of version 3.1
    with respect to quoted arguments to the conditional command’s =~ operator.

    which causes your command to behave differently:

    [[ "hello" =~ "he.*" ]] && echo YES || echo NO
    YES
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The bash man says that variable expansion occurs before command substitution. I was seeking
After reading the Bash man pages and with respect to this post , I
I looked at bash man page and the [[ says it uses Conditional Expressions.
I am playing with using flock , a bash command for file locks to
The man page for Bash says, regarding the -c option: -c string If the
Looking the Array section in the bash(1) man page, I didn't find a way
What is the difference between sh and source ? source: source filename [arguments] Read
I would like to use bash process substitution for a sudo command. For example,
I hate the bash 'history' command. It never finds the history items I want.
I am using following script : #!/bin/bash #script to print quality of man #unnikrishnan

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.