【发布时间】:2013-07-01 10:42:52
【问题描述】:
谁能解释一下原因
VBB:~ me$ test="zut"; echo $test; echo $test > test2; echo "echo test " $test2
输出是:
zut
echo test
VBB:~ me$
而不是
zut
echo test zut
VBB:~ me$
【问题讨论】:
标签: bash variables variable-assignment
谁能解释一下原因
VBB:~ me$ test="zut"; echo $test; echo $test > test2; echo "echo test " $test2
输出是:
zut
echo test
VBB:~ me$
而不是
zut
echo test zut
VBB:~ me$
【问题讨论】:
标签: bash variables variable-assignment
因为echo $test > test2 将输出写入名为 test2 的文件。
这组命令是你所期望的:
test="zut"; echo $test; test2=$test; echo "echo test " $test2
【讨论】:
除了第一个答案,您还可以将文件中的值分配给变量。
echo "$var" ; var= more test2
所以你可以在写入文件 test2 后得到字符串
【讨论】: