[SLUG] arrays

Stephen O'Neill soneill84 at yahoo.co.uk
Mon Nov 28 10:12:33 GMT 2005


Martin Webb wrote:
> array=( `cat "$filename"`)     #  Loads contents from data file 
I'd always use perl for things like this... however, does something like 
this work?

array = `cat "$filename" | sed -e "s/$/'/g" -e "s/^/'/g"`

The reason you had problems was that array = ()  takes a list of values 
delimited by a whitespace. To avoid this you need to quote your values. 
The sed attempts to replace the input from cat's beginning and endings 
of lines with a quote.

Steve O

		
___________________________________________________________ 
To help you stay safe and secure online, we've developed the all new Yahoo! Security Centre. http://uk.security.yahoo.com




More information about the Scarborough mailing list