Home > Computers, Gnu/Linux > Generating number sequences in shell scripts

Generating number sequences in shell scripts

February 21st, 2009

I learned this technique from a fellow participant .

$ yes |nl |head -100 |cut -f1

You can remove the  new lines as below.

$  yes |nl |head -100 | cut -f1| tr ‘\n’ ‘\t’


Otherwise, my course is progressing well. I wrote a simple file transfer daemon and implemented  the client..  Now, I have to do the same with pthreads and non blocking calls.  We had the first glimpse of kernel programming today when some kernel data structures for process and memory managment was iintroduced. I have to read  a lot to get the exact picture.

Categories: Computers, Gnu/Linux Tags:
  1. February 21st, 2009 at 23:01 | #1

    Why not just use the for loop?
    for ((i=1;i<=100;i++)); do echo $i; done

  2. vu2swx
    February 23rd, 2009 at 18:04 | #2

    @ Binny
    Sure I know that. But I was seeing ‘yes’ being used for it for the first time

  3. February 24th, 2009 at 02:11 | #3

    Interesting use for yes ! for normal use:
    seq 100
    is probably more efficient.

Comments are closed.