Question

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

Was it helpful?

Solution

You can safely do:

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

OTHER TIPS

damn... figure it out myself

for i in {1..7} 9

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;
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top