如何在Shell读取文件并赋值

时间:2021-11-19 02:34:32

sys_info=$(cat /usr/local/sysconfig.txt)
var=`echo   $sys_info   |   awk   -F ', '   '{print   $0} '   |   sed   "s/,/   /g "`

ip=$(echo $var | awk '{print $1}')
netmask=$(echo $var | awk '{print $2}')
gateway=$(echo $var | awk '{print $3}')
db_ip=$(echo $var | awk '{print $4}')
record_ip=$(echo $var | awk '{print $5}')