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*

3
  • Thanks, this works. I've never seen shopt -s nullglob before but it makes the difference here. I just hope it doesn't trigger any problems in the remainder of the script (at least it does weird things to normal Bash shell). Can you turn that mode off later in the script? Commented Nov 12, 2013 at 10:07
  • 1
    @Jonik Sure, just call shopt -u nullglob. It could cause problems if your script does some things that rely on POSIX null globbing behaviour. help shopt may also give you some useful information about it. Commented Nov 12, 2013 at 10:10
  • if you have files FOO_1.out and FOO_1.arc and you only want to match arc files then this doesn't work and files=( FOO*.arc ) will return 1 even you only have a FOO_1.out which is not desired Commented Jul 24, 2022 at 12:31