[Shell] Read the configuration line by line to obtain the parameter execution command | shell reads the configuration file

conf.txt

172.17.31.53:12345 1 1 10000 10 1024
172.17.31.53:12345 1 1 10000 10 2048
172.17.31.53:12345 1 1 10000 10 4096
172.17.31.53:12345 1 1 10000 10 8192

readconf.sh

xargs -I{} echo  {} < ./conf.txt

Replace echo with your own script/program

 

Method Two:

a=('1 2 3'  '4 5 6'  '7 8 9')
 
for i in "${a[@]}" ; do
b=($i) #此时b就相当于二维数组里面的一维数组了,然后可以再次遍历
    for j in "${b[@]}"; do
        #do someting
    done
done

https://www.cnblogs.com/wyf-349/p/11236939.html

 

The shell script reads the file line by line into a two-dimensional array

#!/bin/bash
unset array
for x in `cat xxx.properties`
{
    #字符串截取:从左至右第一个'='之前的内容
    #echo ${x%%=*}
    #字符串截取:从左至右第一个'='之后的内容
    #echo ${x#*=}
    array[${#array[@]}]="${x%%=*} ${x#*=}"
}

echo ${#array[@]}
echo ${array[@]}

 

Guess you like

Origin blog.csdn.net/bandaoyu/article/details/114686753