bash script question

Polytropon freebsd at edvax.de
Tue Dec 1 20:04:48 UTC 2009


On Tue, 1 Dec 2009 11:48:43 -0800 (PST), Dánielisz László <laszlo_danielisz at yahoo.com> wrote:
> I just find out:
> 
> #!/usr/local/bin/bash
> export IFS=" "
> cuc=$*
> mkdir "cuc"

The $* variable will expand to all arguments given on the
command line, e. g.

	$ ./myscript foo bar baz

will result in

	mkdir "foo bar baz"

and so create a directory named

	foo\ bar\ baz

including the spaces. If you only want to access the first
parameter, use $1, and for good form, check it before
further processing. Your use of quotes to include the
parameter is already good form. :-)



-- 
Polytropon
Magdeburg, Germany
Happy FreeBSD user since 4.0
Andra moi ennepe, Mousa, ...


More information about the freebsd-questions mailing list