[plug] Bash script help

James Devenish devenish at guild.uwa.edu.au
Mon May 3 19:03:01 WST 2004


In message <4096256A.30804 at wasp.net.au>
on Mon, May 03, 2004 at 02:56:42PM +0400, Brad Campbell wrote:
> brad at srv:~$ for i in /dev/sda[1-9] ; do echo $i ; done
[...]
> How do I do it for sda[1-12] ?
> 
> brad at srv:~$ for i in /dev/sda[1-12] ; do echo $i ; done

(1) It's matching a pattern, not generating one. So you could probably
do much the same thing with "/dev/sda? /dev/sda??" in place of
"/dev/sda[1-9]". However, that would catpure "too many". So, you would
have to do "/dev/sda[1-9] /dev/sda1[0-2]" instead.

(2) In zsh, you can specify a range like "5 to 12" using
"/dev/sda<5-12>"





More information about the plug mailing list