I'd like to retrieve the result of a
echo $1/*.pem
and put the result in a array.
I tried:
a = echo $1/*.pem | grep pem *
or
a = echo $1/*.pem
It fails.
When I do:
echo $1/*.pem
it display the good result
/opt/tmp/a.pem /opt/tmp/ab.pem
You can let bash
do the expansion and use parenthesis to cast an array without the use of echo
:
a=( "$1"/*.pem )
echo "${a[@]}"
You can use echo
but you'll have to use command substitution to reassign the output of the echo
command to the array, and you will have problems if you have spaces in the name of your path:
a=( $(echo $1/*.pem) )
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.