Creating sequential lists of numbers in tcsh

I tried to find a workaround for defining lists of consecutive numbers in tcsh, i.e. instead of doing:

i = ( 1 2 3 4 5 6 8 9 10 )

I would like to do something like this (knowing that this does not work)

i = ( 1..10 )

This would be especially useful in foreach loops (I know what I can use just trying to find an alternative).

Looking around, I found this:

foreach $number (`seq 1 1 9`)
...
end

Discovered that here . It is said that it will generate a list of numbers starting with 1, with a step of 1 ending with 9.

I tried, but it did not work. Obviously, seq is not a command. Does it exist or is it just wrong?

Any other ideas?

+3
source share
1 answer

seq , , , , POSIX. , errosr . ?

foreach number ( `seq 1 9` )
    echo $number
end

seq.

, seq awk:

foreach number ( `awk 'BEGIN { for (i=1; i<=9; i++) print i; exit }'` )

Update

:

  • seq, jot (BSD/OSX):

    foreach number ( `jot 9` )
    

    jot, seq .

  • bash :

    for number in {1..9}
    
+6

Source: https://habr.com/ru/post/1769290/


All Articles