Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

5
  • 15
    @Ruslan That doesn't work. You should do ( GLOBIGNORE="*.org"; rm -i foo* ) Commented Mar 9, 2017 at 11:20
  • 17
    Note if you want to expand the list of ignored, separate with a colon, such as GLOBIGNORE="*foo*:*bar*" Commented May 8, 2019 at 18:45
  • 2
    Hmmm I ended up needing to add a && between setting the GLOBIGNORE and the command following where it is supposed to be applied. I assume that if you don't, the entire expression is evaluated and all * snippets are expanded - at which point it is too late to set GLOBIGNORE. In other words, for this example: GLOBIGNORE="*.org" && rm -i foo* Commented Jul 15, 2021 at 18:56
  • 2
    Thank you @consideRatio for the explanation. So that's why the subshell and semicolon were suggested by DBedrenko. The OP simply doesn't work and any version that does work leaves you an environment variable to clean up. Commented Aug 7, 2021 at 16:46
  • 1
    Worth noting that there are bugs in how this variable is processed. Let's say, we have touch a.deb b.deb c.deb. So, first of all, it's completely ignored when it's inherited. So e.g. this way GLOBIGNORE="/tmp/a.*" bash -c 'ls /tmp/*.deb still prints a.deb even though the bash subcommand sees it just fine. Then, two globs don't work either, so e.g. this command bash -c 'GLOBIGNORE="*a.*"; ls /tmp/*.deb' prints a.deb as well. Commented Apr 23, 2024 at 13:32