当我这样做时:
echo -e "test1 test2 test3\ntest1 test2 test3" | awk '{print($2)}'
Run Code Online (Sandbox Code Playgroud)
我得到打印输出:
test2
test2
Run Code Online (Sandbox Code Playgroud)
但是当我喜欢这样的时候:
test=`echo -e "test1 test2 test3\ntest1 test2 test3" | awk '{print($2)}'`
echo $test
Run Code Online (Sandbox Code Playgroud)
我得到打印输出:
test2 test2
Run Code Online (Sandbox Code Playgroud)
我希望结果作为第一个示例中的列,但也希望它在变量中.我怎样才能做到这一点?