Populating an array in BASH

Charles Curley charlescurley at charlescurley.com
Tue Jun 23 19:36:47 MDT 2009

I'd like to create an array in BASH, populating it with the results of
a find command piped through some other tools, one array element per
file found. Something like:

array=( $(find .... ) )

works stand-alone. But surround it with if  ... else ... fi, and I get:

Syntax error: "(" unexpected (expecting "fi")

If I leave out the outer parentheses, I get the results as one long
string, not what I want.

I think this used to work. Ideas?

ccurley at dragon:~$ bash --version
GNU bash, version 3.2.48(1)-release (i486-pc-linux-gnu)
Copyright (C) 2007 Free Software Foundation, Inc.
ccurley at dragon:~$ 


Charles Curley                  /"\    ASCII Ribbon Campaign
Looking for fine software       \ /    Respect for open standards
and/or writing?                  X     No HTML/RTF in email
http://www.charlescurley.com    / \    No M$ Word docs in email

Key fingerprint = CE5C 6645 A45A 64E4 94C0  809C FFF6 4C48 4ECD DFDB

More information about the PLUG mailing list