Jul 27

It’s very easy to iterate over lines of standard output of command.

Here is an example:

#!/bin/sh
 
for i in `seq 0 5 15`
do
	echo $i
done

The output is:

0
5
10
15

seq 0 5 15 iterates from 0 to 15 with step 5

`command` executes command and return its standard output


one comment so far...

  • Wojciech Jamrozy blog - [Ubuntu] Packages auto-purging script Said on August 11th, 2009 at 7:02 pm:

    [...] 3rd field (in this case retrieve name of packages to delete) dpkg -P package purges package This link explains other things. It can be added to /etc/crontab as: 09 18 * * * root for i in `dpkg -l | [...]

leave a reply