Bash - file line to array

Bruno Galindro da Costa bruno.galindro at gmail.com
Fri Sep 24 00:04:01 UTC 2010


Hi!

   Is there any other method to transform lines of a file to an array
variable than these bellow?

### MY FILE CONTENT ####
# cat file
[SERVER1]
IP=0.0.0.0
[SERVER2]
IP=0.0.0.0

### METHOD 1 ####
# CONF=( $(cat file) )

### METHOD 2 ####
# CONF=( $(<file) )

    If I execute these two methods on GNU bash, version 3.00.16(1)-release
(i386-redhat-linux-gnu) (bash-3.0-31.el4.i386.rpm), I´ll give this result in
array:

# echo ${CONF[*]}
1 IP=0.0.0.0 [SERVER2] IP=0.0.0.0

    If I execute these two methods on GNU bash, version 3.1.17(1)-release
(i686-redhat-linux-gnu) (bash-3.1-16.1.el5.i386.rpm), I´ll give this result
in array:

# echo ${CONF[*]}
[SERVER01] IP=0.0.0.0 [SERVER02] IP=0.0.0.0


See the diference? The version 3.00.16 replace the string [SERVER1] by 1,
and the version 3.1.17 do nothing.

Why??!! This is a BUG?

-- 
Att.
Bruno Galindro da Costa
bruno.galindro at gmail.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.fedoraproject.org/pipermail/users/attachments/20100923/c4e57797/attachment.html 


More information about the users mailing list