gpt4 book ai didi

shell - “${x%% *}” 在 sh 中是什么意思?

转载 作者:行者123 更新时间:2023-12-04 15:45:34 25 4
gpt4 key购买 nike

我刚刚在 makefile 中看到了“$${x%% *}”,这意味着 sh 中的“${x%% *}”。
为什么这样写?

https://unix.stackexchange.com/questions/28994/how-can-a-makefile-detect-whether-a-command-is-available-in-the-local-machine

determine_sum = \
sum=; \
for x in sha1sum sha1 shasum 'openssl dgst -sha1'; do \
if type "$${x%% *}" >/dev/null 2>/dev/null; then sum=$$x; break; fi; \
done; \
if [ -z "$$sum" ]; then echo 1>&2 "Unable to find a SHA1 utility"; exit 2; fi

checksums.dat: FORCE
$(determine_sum); \
$$sum *.org

另外,如何搜索 ${x%% *}在谷歌?

最佳答案

${x%% *}替换 x 的值最左边的空格和它右边的所有内容都被删除的变量。

http://www.gnu.org/software/bash/manual/html_node/Shell-Parameter-Expansion.html

对于第二个问题,我没有答案。

关于shell - “${x%% *}” 在 sh 中是什么意思?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16414314/

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