【问题标题】:explain bash variable assignement output解释 bash 变量赋值输出
【发布时间】: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


    【解决方案1】:

    因为echo $test > test2 将输出写入名为 test2 的文件。

    这组命令是你所期望的:

    test="zut"; echo $test; test2=$test; echo "echo test " $test2
    

    【讨论】:

      【解决方案2】:

      除了第一个答案,您还可以将文件中的值分配给变量。

      echo "$var" ; var= more test2
      

      所以你可以在写入文件 test2 后得到字符串

      【讨论】:

        猜你喜欢
        • 2010-12-29
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2012-04-28
        • 1970-01-01
        • 1970-01-01
        • 2012-04-13
        相关资源
        最近更新 更多