gpt4 book ai didi

linux - 将列表中的每一行与一个数字进行比较

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

我有一个这样的列表:

cat mandi
234
562
3256
77
356

我想将此列表的每一行与一个数字 x 进行比较,然后在它大于一个数字时打印其输出。

我试过这个脚本,但没有达到我预期的结果。

#!/bin/bash

i=1;

for i in {1..$mandi}
do
if [ "$i" -gt 10000 ];
then
echo "probleme"
else
echo "Not problem"
fi
done

最佳答案

试试这个:

#!/bin/bash     

while read line;
do
if (( ${line} > 1000 ));
then
echo "problem"
else
echo "good"
fi
done < mandi

关于linux - 将列表中的每一行与一个数字进行比较,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43630644/

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