GBase 8a
其他
文章

shell脚本中拆分单列赋值多个参数

发表于2025-07-28 14:49:3951次浏览0个评论

table_list内容

table_schema|table_name|table_schema_1|table_name_1

test_db1|test_tb1|test_db2|test_tb2

对其内容进行拆分,使其中值分别赋值到四个参数上,可以参考如下:

while read line
do
oifs=$IFS
IFS='?|'
set -- $line
from_schema=$1
from_table=$2
to_schema=$3
to_table=$4
IFS=$oifs
echo $from_schema $from_table $to_schema $to_table
done < table_list

评论

登录后才可以发表评论