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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T11:08:11+00:00 2026-05-29T11:08:11+00:00

My colleague, Ryan, came to me with a bug in his Bash script, and

  • 0

My colleague, Ryan, came to me with a bug in his Bash script, and I identified the problem with this test:

$ mkdir ryan
$ mkdir ryan/smells-bad
$ FOO=ryan/smells-*
$ echo $FOO
ryan/smells-bad
$ touch $FOO/rotten_eggs
touch: cannot touch `ryan/smells-*/rotten_eggs': No such file or directory

From this I infer that the globbing happens during the echo command, not when the variable FOO is created.

We have a couple of workarounds, in descending order of ungracefulness:

touch `echo $FOO`/rotten_eggs

Or:

pushd
cd $FOO
touch rotten_eggs
popd

But neither is satisfying. Am I missing a trick?

  • 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-29T11:08:11+00:00Added an answer on May 29, 2026 at 11:08 am

    The problem is that the glob will only expand if the file “rotten_eggs” exists, because it is included in the glob pattern. You should use an array.

    FOO=( ryan/smells-* )
    touch "${FOO[@]/%//rotten_eggs}"
    

    The FOO array contains everything matched by the glob. The expansion using % appends /rotten_eggs to each element.

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

Sidebar

Related Questions

A colleague came to me with a problem that I managed to answer but
One colleague of mine has troubles during the DllMain Detach process. His bug seems
My colleague and I came across this when looking into getting the invocation list
A colleague of mine came across an article on codeproject over the weekend which
A colleague of mine asked me to write a homework for him. Although this
A colleague has a batch script program which needs to to run on a
My colleague wrote the following stackoverflow question: other stack overflow question on this topic
A colleague has installed VS2008 Team Explorer (as part of his role in Scrum)
My colleague's code looked like this: void copy(std::string const& s, char *d) { for(int
A colleague and I are going back and forth on this issue and I'm

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.