Bash 使用查找和大括号扩展查找脚本

Bash 使用查找和大括号扩展查找脚本,bash,Bash,我试图在bash中找到一些脚本 FOLDERS='one,two' eval find "{$FOLDERS}/*.sh" 当然,我想在没有评估的情况下做这件事。但删除eval只会带来: find: {one,two}/*.sh: No such file or directory 如何使用大括号展开之类的方法使find接受一组可变文件夹,而不使用循环?使用数组,然后可以直接展开数组元素 folders=(one two) find "${folders[@]}" -name '*.sh'

我试图在bash中找到一些脚本

FOLDERS='one,two'
eval find "{$FOLDERS}/*.sh"
当然,我想在没有评估的情况下做这件事。但删除eval只会带来:

find: {one,two}/*.sh: No such file or directory

如何使用大括号展开之类的方法使find接受一组可变文件夹,而不使用循环?

使用数组,然后可以直接展开数组元素

folders=(one two)
find "${folders[@]}" -name '*.sh'
这样做的好处是,即使文件夹中有空格、逗号或其他特殊字符,它也能工作

folders=('comma,separated,name' 'My Documents')