Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我将多行存储在一个变量中,当我尝试访问它们时,它显示在一行中。
$ echo -e "A\nB" A B $ VAR=`echo -e "A\nB"` $ echo $VAR A B
让我知道有什么方法可以使输出与命令相同。我希望 A,B 在访问它时处于不同的行中。
回显时需要引号:
$ var=$(echo -e "A\nB") $ echo "$var" A B
$ VAR= echo -e "A\nB" $ echo "$VAR" AB
echo -e "A\nB"