Linux Blog

Sequences with seq

Filed under: Quick Linux Tutorials,Shell Script Sundays — TheLinuxBlog.com at 9:28 pm on Sunday, July 19, 2009

I’m going to keep this one short since time I’ve had a serious lack of time recently. If you need to free up some time by putting repetitive commands into loops, you can use the command seq.

Basically, you can use any generic loop such as the while or for loop. Here are two examples:

for i in `seq 1 10`; do echo $i; done;
 
seq 1 10 | while read i; do echo $i; done;

These both count and echo from 1 to ten. Replace the echo $i; with whatever it is you want to do. You can use sleep, to sleep for a number of seconds, and any other logic you wish here.

Man Pages for commands in this post »

seq

3 Comments »

Comment by open source tips

July 17, 2010 @ 8:10 am

Thanks for sharing.

Comment by affordable web hosting

January 22, 2014 @ 10:15 am

Ok I’ve a pc desktop at home which i want to set up as being a web server features
are:intel pentium 4 processor at 2.4 ghz2 show of ram2 x hard
cds eighty hdd (process) 250 gb hdd (storage)2 x NIC s broadcom ethernet
(what i mean 2 network cards hooked on that mobo)windows server 2003 installed on it.i
just want to turn it to a web server in order to make other pc s in my household able to access it,any ideas?sorry
about my eng thanks I understand how to set up a localhost, but how to you set it up which means your websites are in reality on
the web and accessible from other computers? Can I ask
you why you might like to do that, before I asnwer?

Check out my weblog affordable web hosting

Comment by Jedras

November 18, 2014 @ 12:13 pm

Hi, instead of running external programs and strange oneliners just use zsh as your shell and have this built in:
$ for i in {1..6}
do
echo $i
done
You can also use it as:
$ echo blah{1..6}
blah1 blah2 blah3 blah4 blah5 blah6

Newer versions of bash have this as well but khm.. bash has been bashed lately for some bad bugs, so let’s just use zsh.

RSS feed for comments on this post. TrackBack URI

Leave a comment

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>