和 的 CentOS/RHEL 8 等价物(或它们合并到的软件包的名称)是什么libgssglue
,openjpeg-libs
如果有的话(它们的功能现在不受支持吗)?我非常感谢答案和用于找到答案的方法。谢谢!
主页
/
user-334513
Levi Uzodike's questions
Levi Uzodike
Asked:
2019-02-01 11:10:41 +0800 CST
我试图找到最有效的方法来遍历某些值,这些值是在空格分隔的单词列表中彼此相距一致数量的值(我不想使用数组)。例如,
list="1 ant bat 5 cat dingo 6 emu fish 9 gecko hare 15 i j"
所以我希望能够只遍历列表并且只访问 1、5、6、9 和 15。
编辑:我应该明确表示我试图从列表中获取的值在格式上不必与列表的其余部分不同。使它们与众不同的仅仅是它们在列表中的位置(在这种情况下,位置 1,4,7...)。所以列表可能是1 2 3 5 9 8 6 90 84 9 3 2 15 75 55
,但我仍然想要相同的数字。而且,假设我不知道列表的长度,我希望能够做到这一点。
目前我想到的方法有:
方法一
set $list
found=false
find=9
count=1
while [ $count -lt $# ]; do
if [ "${@:count:1}" -eq $find ]; then
found=true
break
fi
count=`expr $count + 3`
done
方法二
set list
found=false
find=9
while [ $# ne 0 ]; do
if [ $1 -eq $find ]; then
found=true
break
fi
shift 3
done
方法 3 我很确定管道使这是最糟糕的选择,但出于好奇,我试图找到一种不使用 set 的方法。
found=false
find=9
count=1
num=`echo $list | cut -d ' ' -f$count`
while [ -n "$num" ]; do
if [ $num -eq $find ]; then
found=true
break
fi
count=`expr $count + 3`
num=`echo $list | cut -d ' ' -f$count`
done
那么什么是最有效的,或者我错过了一个更简单的方法?