开发者

How to skip a particular number when iterate over a range sequence number?

Let's said

for i in {1..9}
do
  if test $i -ne 8
  then 
    echo $i 
  fi
done

If there a way to skip number 8 from this sequence {1..9} without doing the comparison?

PS: GNU bash, version 3.00开发者_如何学JAVA


damn... figure it out myself

for i in {1..7} 9


You can safely do:

{1..N} {N+2..P}


just test if it's the value(s) you don't want and then continue which just finishes this iteration and goes on to the next one.

if $test == 8{
    continue;
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜