gpt4 book ai didi

linux - 为什么 find 在反引号内产生一个空的新行?

转载 作者:太空宇宙 更新时间:2023-11-04 09:40:25 25 4
gpt4 key购买 nike

出于某种原因,在反引号和双引号内解析变量名会导致空新行。

search="randomsite";
res="`find /var/www -maxdepth 2 -mindepth 2 -type d -name '${search}'`";
echo $res

最佳答案

使用 $() 而不是反引号 - 它们更易于阅读和嵌套...

res=$(find /var/www -maxdepth 2 -mindepth 2 -type d -name "${search}")

关于linux - 为什么 find 在反引号内产生一个空的新行?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22220241/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com