I would like to apply parameter expansion (e.g. search and replace) in order to remove spaces from the brace expansion ({a..z}
). It is possible?
So I've the following range: {a..z}
which consist all letters and I would like to remove spaces in one go.
Here is longer example:
$ echo {a..z}
a b c d e f g h i j k l m n o p q r s t u v w x y z
$ az=$(eval echo {a..z})
$ echo $az
a b c d e f g h i j k l m n o p q r s t u v w x y z
$ echo ${az// /}
abcdefghijklmnopqrstuvwxyz
Is it possible to apply parameter expansion directly on a range? Or at least to make it in one expression, especially without assigning this to variable?
One example usage is to specify all parameters dynamically for getopts
, for example:
while getopts {a..z} arg; do
printf $arg
done
however this doesn't work (e.g. ./az.sh -a -b -c
) as spaces from that range needs to be removed first.