Hi, Some remarks: - just try « expr ${VAR} + 1 » (with blanc between car) - use simple redirection (« < ») with a simple reference to file (« done < list.txt ») - use « ${VAR} » to manage variables - you can use numeric notation to increment VAR (p.e. « total=$(( ${total} + 1 )) ») An other way to do that: AWK. Regards > Le 23 juil. 2020 à 15:46, Jerry Geis <jerry.geis at gmail.com> a écrit : > > I have a simple script: > #!/bin/bash > # > index=0 > total=0 > names=() > ip=() > while read -r LINE > do > NODENAME=` echo $LINE | cut -f 1 -d ','` > IP=` echo $LINE | cut -f 2 -d ','` > names[index]="$NODENAME" > ip[index]="$IP" > index=`expr index+1` > total=`expr total+1` > done <<< $(cat list.txt) > > simple file: > more list.txt > name1,ip1 > name2,ip2 > name3,ip3 > > output when running: > sh -x ./test_bash.sh > + index=0 > + total=0 > + names=() > + ip=() > ++ cat list.txt > + read -r LINE > ++ echo name1,ip1 name2,ip2 name3,ip3 > ++ cut -f 1 -d , > + NODENAME=name1 > ++ echo name1,ip1 name2,ip2 name3,ip3 > ++ cut -f 2 -d , > + IP='ip1 name2' > + names[index]=name1 > + ip[index]='ip1 name2' > ++ expr index+1 > + index=index+1 > ++ expr total+1 > + total=total+1 > + read -r LINE > + echo name1 > name1 > > > Question is why is it not reading one line at a time ? > All I get is the first one. > I'm just trying to build the array of the items in the file and then list > them at this point. > > Thanks > > Jerry > _______________________________________________ > CentOS mailing list > CentOS at centos.org > https://lists.centos.org/mailman/listinfo/centos -- Pierre Malard Responsable architectures système GeoSUD IRD - UMR Espace-Dev - UMS CPST Maison de la Télédétection 500 rue Jean-François Breton 34093 Montpellier Cx 5 France « L'utopie, c'est la vérité de demain » Victor Hugo (1802-1885) |\ _,,,---,,_ /,`.-'`' -. ;-;;,_ |,4- ) )-,_. ,\ ( `'-' '---''(_/--' `-'\_) πr perl -e '$_=q#: 3|\ 5_,3-3,2_: 3/,`.'"'"'`'"'"' 5-. ;-;;,_: |,A- ) )-,_. ,\ ( `'"'"'-'"'"': '"'"'-3'"'"'2(_/--'"'"' `-'"'"'\_): 24πr::#;y#:#\n#;s#(\D)(\d+)#$1x$2#ge;print' - --> Ce message n’engage que son auteur <-- -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 833 bytes Desc: Message signed with OpenPGP URL: <http://lists.centos.org/pipermail/centos/attachments/20200723/dd4fbfdf/attachment-0005.sig>