0

如何将此命令行插入变量中?:

echo "abc:def" | awk -F':' '{print "field1: "$1 "\nfield2: "$2}'

提前致谢

4

2 回答 2

0

请试试这个

testVar=`echo "abc:def" | awk -F':' '{print "field1: "$1 "\nfield2: "$2}'`
echo $testVar
于 2013-05-16T08:22:35.443 回答
0

使用eval

eval `echo "abc:def" | awk -F':' '{print "export field1="$1 "\nexport field2="$2}'`
于 2013-05-16T08:28:39.423 回答