Unix Shell - Re: Catching results of a command in to array in shell

This is Interesting: Free IT Magazines  
Home > Archive > Unix Shell > February 2006 > Re: Catching results of a command in to array in shell





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author Re: Catching results of a command in to array in shell
Janis Papanagnou

2006-02-20, 5:54 pm

Chris F.A. Johnson wrote:
> On 2006-02-20, sreenivasulu vunnam wrote:
>
>
>
> You don't want to do that; 'ls' is unnecessary, and will break your
> script if the filenames contain spaces or other characters special
> to the shell.
>
> Do you really need it in an array? You can do, for example:
>
> for file in *.xml
> do
> : ...
> done
>
> If you want it in an array, and are using bash2+ or ksh93:
>
> array=( *.xml )
>


Or use

set -- *.xml

and access the $# elements through $1, $2, ...

Janis
Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com