shell scripting : seq prints a sequence of numbers

Filed Under (bash) by Amandine on 08-02-2010

I often need to execute a loop x times, and I’m just too lazy to write a i++ style algorithm… the command seq is made for me :)

Easy to use, just does what I need from it, here’s a extract from the man page :

NAME
       seq - print a sequence of numbers

SYNOPSIS
       seq [OPTION]... LAST
       seq [OPTION]... FIRST LAST
       seq [OPTION]... FIRST INCREMENT LAST

So…

$ seq 10
1
2
3
4
5
6
7
8
9
10
$ seq 5 10
5
6
7
8
9
10
$ seq 10 2 20
10
12
14
16
18
20
$ for i in `seq 5`; do echo 'hello!'; done;
hello!
hello!
hello!
hello!
hello!

Great ! :p

Similar Posts:

Share and Enjoy:
  • email
  • Print
  • RSS
  • PDF
  • Add to favorites
  • Digg
  • Google Bookmarks
  • del.icio.us
  • Facebook
  • blogmarks
  • FriendFeed
  • LinkedIn
  • MySpace
  • Netvibes
  • Ping.fm
  • Reddit
  • StumbleUpon
  • Tumblr
  • Twitter
  • Technorati
  • Slashdot
  • Socialogs
  • Wikio
  • Yahoo! Bookmarks

Comments are closed.