如
ridiculous_fish所述,您可以使用本机线分割机制.
原文链接:https://www.f2er.com/bash/383991.htmlresult of a command substitution becomes a list by splitting on newlines (
$IFS
)
所以
>每行列出一个项目;
然后在命令替换中捕获.
清单
function __list_public_keys for key in ~/.ssh/*.pub echo $key end end
产量
$__list_public_keys /home/ed8/.ssh/id_rsa.blabla.pub /home/ed8/.ssh/id_rsa.pub /home/ed8/.ssh/id_rsa.test.pub
捕获
function __add_keys set keys (__list_public_keys) echo "[" $keys "]" end
产量
$__add_keys [/home/ed8/.ssh/id_rsa.blabla.pub] [/home/ed8/.ssh/id_rsa.pub] [/home/ed8/.ssh/id_rsa.test.pub]