[SLUG] arrays

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


Martin Webb wrote:
> I'm using:
> array=( `cat "$filename"`)     #  Loads contents from data file 
I tried this:
array=(`cat "test2.txt" | sed -e 's/^/"/g' -e 's/$/"/g' | tr '\n' ' 
'`);echo "${array[0]}";

.... the expansion:
cat "test2.txt" | sed -e 's/^/"/g' -e 's/$/"/g' | tr '\n' ' '

Provides:
"This is line 1" "This is line 2"

If I do:
array=("This is line 1" "This is line 2");echo "${array[0]}";

I get:
"This is line 1"

However, if I do the command at the top I get:
"This

So I don't understand. Is your script young? Do you like sh/perl?

Steve O

		
___________________________________________________________ 
Yahoo! Model Search 2005 - Find the next catwalk superstars - http://uk.news.yahoo.com/hot/model-search/




More information about the Scarborough mailing list