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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T02:16:10+00:00 2026-05-25T02:16:10+00:00

I am not getting results back from grep when I call it with a

  • 0

I am not getting results back from grep when I call it with a param containing curly braces using Ruby’s “ or %x{} expressions.

Say I have these files in an empty directory:

$ echo '**hello**' > hello.md
$ echo 'hello' > hello.txt

If I only want results matching a single extension, Ruby works as expected:

$ grep -rn hello . --include=*.txt
./hello.txt:1:hello

$ grep -rn hello . --include=*.md
./hello.md:1:**hello**

$ irb

ree-1.8.7-2011.03 :001 > `grep -rn hello . --include=*.txt`
=> "./hello.txt:1:hello\n"

ree-1.8.7-2011.03 :002 > %x{grep -rn hello . --include=*.md}
=> "./hello.md:1:**hello**\n" 

ree-1.8.7-2011.03 :003 > exit

But if I ask for results matching either extension, using grep’s curly brace syntax, no results come up with Ruby:

$ grep -rn hello . --include=*.{txt,md}
./hello.txt:1:hello
./hello.md:1:**hello**

$ irb

ree-1.8.7-2011.03 :001 > `grep -rn hello . --include=*.{txt,md}`
=> ""

ree-1.8.7-2011.03 :002 > %x{grep -rn hello . --include=*.{txt,md}}
=> ""

Edit: echoing works, but command results are still empty:

ruby-1.9.2-p180 :004 > `echo grep -rn hello . --include=*.{txt,md}`
=> "grep -rn hello . --include=*.{txt,md}\n" 

ruby-1.9.2-p180 :005 > `grep -rn hello . --include=*.{txt,md}`
=> "" 

How can I debug this and see the actual command being executed? And what’s the correct way to execute system commands with curly braces in the params from Ruby?

  • 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-25T02:16:11+00:00Added an answer on May 25, 2026 at 2:16 am

    Here’s a guess: %x{} is using /bin/sh which isn’t behaving like /bin/bash (or your usual shell).

    This pattern:

    *.{txt,md}
    

    is expanded by your shell just like all the other file globbing patterns. When you run your command from within irb, Ruby is probably using /bin/sh to execute the command and on your system, /bin/sh behaves like a plain POSIX shell which doesn’t understand the *.{a,b} globbing syntax.

    Try invoking bash directly:

    irb> `bash -c 'grep -rn hello . --include=*.{txt,md}'`
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using IMDbPY to retrieve data from IMDb. I'm getting the right results and
hi im trying to using flashVars however for some reason there not getting sent
I'm getting strange results testing the return value from a function. This code is
I am getting Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource
I'm not getting any errors as such just a minor performance issue. EXPLAIN SELECT
I am not getting why the colon shifted left in the second time >>>
For some reason I'm not getting this. (Example model below) If I write: var
So my code is below. I'm not getting any errors and it places everything
I have been reading up on Cloud computing on here and still not getting
I feel like this might be really simple but I'm just not getting it

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.