Bash - file line to array

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxx
-- 
users mailing list
users@xxxxxxxxxxxxxxxxxxxxxxx
To unsubscribe or change subscription options:
https://admin.fedoraproject.org/mailman/listinfo/users
Guidelines: http://fedoraproject.org/wiki/Mailing_list_guidelines

[Index of Archives]     [Current Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]     [Fedora Docs]

  Powered by Linux