Quantcast
Channel: Wild card expansion that works on command line but not in a bash script - Ask Ubuntu
Viewing all articles
Browse latest Browse all 2

Answer by steeldriver for Wild card expansion that works on command line but not in a bash script

$
0
0

If you are using the default Ubuntu ~/.bashrc file, then extended globbing is enabled by default1 for interactive shells - which is why it works on the command line.

Inside a script however, you will need to enable it with

shopt -s extglob

shopt is documented in man bash under the SHELL BUILTIN COMMANDS section, or via the shell's online help

help shopt

1 albeit rather opaquely, via bash completions. See for example Where is bash's “shopt extglob” turned on for my interactive shell?


Viewing all articles
Browse latest Browse all 2

Trending Articles