Re: put find output in an array
First Lensman wrote:
> Your second option was great but it only allows one pass on the
> results.
>
> > array=( $(find . -type f -mtime ${maxTime}) )
> > for f in ${array[*]}
> > do
> > #something with "$f"
> > done
>
> I tried this option but it doesn't like the outer parenthesis on the
> first line for some reason.
> Is this a mistype?
>
that worked fine in the following shells:
1) Linux 2.6.12-9-386 GNU/Linux,
GNU bash, version 3.00.16(1)-release (i486-pc-linux-gnu)
2) SunOS 5.8
GNU bash, version 2.03.0(1)-release (sparc-sun-solaris)
not working under 'tcsh'.
Also, if there are whitespaces within filenames, it might be better to
reset IFS before assigning array, like:
IFS= ; arrar=( $(find . -type f -mtime ${maxTime}) )
Xicheng
|