There is a problem when I use brace expansion in bash

Viewed 95

There is a problem when I use brace expansion in bash.

I want to get a string of a b c, so i use the command of echo {a..c}, but i just get a string of {a..c}. The operating system I used is CentOS 7.9.

1 Answers

Enable the braceexpand option.

man bash:

-B The shell performs brace expansion (see Brace Expansion above). This is on by default.

to enable:

$ set -o braceexpand # `set -B`
$ echo {a..c}
a b c

to disable:

$ set +o braceexpand # `set +B`
$ echo {a..c}
{a..c}

to get state:

$ set -o | grep braceexpand
braceexpand     on
[[ $- =~ B ]] && echo on || echo off
on
Related