shell读取文件每一行,并将列值赋给变量

shell读取文件每一行,并将列值赋给变量

cat ./db.conf | while read dbhost dbport dbuser dbpasswd

do

echo $dbhost $dbport $dbuser $dbpasswd

done

如果想从第二行开始,则可以使用awk实现

cat ./db.conf | awk 'NR>1' | while read dbhost dbport dbuser dbpasswd

do

echo $dbhost $dbport $dbuser $dbpasswd

done

You may also like...

发表评论