gpt4 book ai didi

linux - 如何理解哈希wget?

转载 作者:塔克拉玛干 更新时间:2023-11-03 01:17:19 25 4
gpt4 key购买 nike

我是 linux bash 的新手,这是一个让我困惑的问题。我不明白“hash wget”。它的目的是什么,为什么要进行 if 检查?

if [ ! -e text8 ]; then
if **hash wget 2>/dev/null**; then
wget http://mattmahoney.net/dc/text8.zip
else
curl -O http://mattmahoney.net/dc/text8.zip
fi
unzip text8.zip
rm text8.zip
fi

最佳答案

如果 wget 可用(在 PATH 中),hash wget 的退出代码为 0,因此执行语句。重定向 2>/dev/null 只是在找不到 wget 时重定向错误消息。在 bash 提示符下使用 help hash 来阅读它的信息。

关于linux - 如何理解哈希wget?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49247140/

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